Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is query dsl entity path limited to four levels?

Tags:

java

querydsl

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?

like image 346
geneqew Avatar asked Oct 15 '14 11:10

geneqew


1 Answers

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

like image 51
Timo Westkämper Avatar answered Oct 09 '22 08:10

Timo Westkämper