8

Im currently using the maven apt plugin to generate the EntityPath base classes.

      <plugin>
            <groupId>com.mysema.maven</groupId>
            <artifactId>maven-apt-plugin</artifactId>
            <version>1.0.4</version>
            <executions>
                <execution>
                    <goals>
                        <goal>process</goal>
                    </goals>
                    <phase>generate-sources</phase>
                    <configuration>
                        <outputDirectory>target/generated-sources/java</outputDirectory>
                        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>com.mysema.querydsl</groupId>
                    <artifactId>querydsl-apt</artifactId>
                    <version>${querydsl.version}</version>
                </dependency>
                <dependency>
                    <groupId>com.mysema.querydsl</groupId>
                    <artifactId>querydsl-jpa</artifactId>
                    <classifier>apt</classifier>
                    <version>${querydsl.version}</version>
                </dependency>
            </dependencies>
        </plugin>

this generates the desired Q classes and it is helpful in building predicates for queries. However i noticed that i always get a null pointer exception whenever i exceed four levels ie:

QFoo.foo.x.y.z

where Z is of type QZ; a generated EntityPath as well.

is this a limitation of the QueryDSL?

geneqew
  • 2,401
  • 5
  • 33
  • 48

1 Answers1

11

Yes, this is a limitation of Querydsl. Since the normal path initialization uses final fields a limit needs to be used. Luckily path initialization can be customized in many ways http://www.querydsl.com/static/querydsl/3.5.0/reference/html/ch03s03.html#d0e2181

Timo Westkämper
  • 21,824
  • 5
  • 78
  • 111