为什么查询 dsl 实体路径限制为四个级别? [英] Why is query dsl entity path limited to four levels?

查看:48
本文介绍了为什么查询 dsl 实体路径限制为四个级别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用 maven apt 插件来生成 EntityPath 基类.

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>

这会生成所需的 Q 类,并且有助于构建查询谓词.但是我注意到每当我超过四个级别时,我总是会得到一个空指针异常,即:

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

其中 Z 是 QZ 类型;生成的 EntityPath 也是如此.

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

这是 QueryDSL 的限制吗?

is this a limitation of the QueryDSL?

推荐答案

是的,这是 Querydsl 的限制.由于正常路径初始化使用最终字段,因此需要使用限制.幸运的是,可以通过多种方式自定义路径初始化 http://www.querydsl.com/static/querydsl/3.5.0/reference/html/ch03s03.html#d0e2181

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

这篇关于为什么查询 dsl 实体路径限制为四个级别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆