Mysema Querydsl:没有 JPAQuery#list() 方法
Mysema Querydsl: There's no JPAQuery#list() method
一些 Mysema Querydsl 用法的在线示例依赖于 JPAQuery#list()
方法,例如this Whosebug answer containing a GROUP BY / COUNT aggregate example. It is also referred to throughout the official documentation.
不过,我在JPAQuery
class上确实没有看到这个方法。它没有出现在 IDE 的自动完成中,也没有出现在 Maven 下载的 JAR 文件中。
我已将这些依赖项添加到我的 Maven 项目中:
<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 从 3.x to the 4.x 行升级时删除了方法 JPAQuery.list
。由于您使用的是4.0.4版本,此方法不再可用。
据我阅读 release notes 的了解,第 4 版在代码库中引入了很多破坏旧代码的重大更改。您有两个选择:
- 降级到最后一个版本3.x行,即3.6.8并使用
list
方法
- 保留版本 4.0.4 并使用
fetch
method instead. Take a look at this GitHub issue 作为更改列表。
一些 Mysema Querydsl 用法的在线示例依赖于 JPAQuery#list()
方法,例如this Whosebug answer containing a GROUP BY / COUNT aggregate example. It is also referred to throughout the official documentation.
不过,我在JPAQuery
class上确实没有看到这个方法。它没有出现在 IDE 的自动完成中,也没有出现在 Maven 下载的 JAR 文件中。
我已将这些依赖项添加到我的 Maven 项目中:
<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 从 3.x to the 4.x 行升级时删除了方法 JPAQuery.list
。由于您使用的是4.0.4版本,此方法不再可用。
据我阅读 release notes 的了解,第 4 版在代码库中引入了很多破坏旧代码的重大更改。您有两个选择:
- 降级到最后一个版本3.x行,即3.6.8并使用
list
方法 - 保留版本 4.0.4 并使用
fetch
method instead. Take a look at this GitHub issue 作为更改列表。