Mysema Querydsl:没有JPAQuery#list()方法 [英] Mysema Querydsl: There's no JPAQuery#list() method
问题描述
一些使用 Mysema Querydsl 的在线示例依赖于JPAQuery#list()
方法,例如此stackoverflow答案,其中包含GROUP BY/COUNT汇总示例.在官方文档中也被引用.
Some online examples for Mysema Querydsl usage rely on the JPAQuery#list()
method, e.g. this stackoverflow answer containing a GROUP BY / COUNT aggregate example. It is also referred to throughout the official documentation.
但是,我只是没有在JPAQuery
类上看到此方法.它不会出现在IDE的自动完成功能中,也不会出现在Maven下载的JAR文件中.
However, I do just not see this method on the JPAQuery
class. It doesn't show up in the IDE's autocomplete, and it's not present in the JAR file downloaded by Maven.
我已将以下依赖项添加到我的Maven项目中:
I have added these dependencies to my Maven project:
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>4.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>4.0.4</version>
</dependency>
为什么没有JPAQuery#list()
方法?
推荐答案
当Querydsl从 4.x 行.由于您使用的是4.0.4版,因此该方法不再可用.
The method JPAQuery.list
was removed when Querydsl upgraded from the 3.x to the 4.x line. Since you are using version 4.0.4, this method is no longer available.
据我阅读发行说明所了解的那样,第4版在代码中进行了许多重大更改破坏较旧代码的基础.您有两种选择:
As I understand from reading the release notes, version 4 introduces a lot of major changes in the code base that breaks older code. You have two options:
- downgrade to the last version of the 3.x line, which 3.6.8 and use the
list
method - keep version 4.0.4 and use the
fetch
method instead. Take a look at this GitHub issue for the list of changes.
这篇关于Mysema Querydsl:没有JPAQuery#list()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!