Mysema Querydsl:没有JPAQuery#list()方法 [英] Mysema Querydsl: There's no JPAQuery#list() method

查看:189
本文介绍了Mysema Querydsl:没有JPAQuery#list()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些使用 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从

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:

  • 降级到3.x行的最新版本,即3.6.8,并使用list方法
  • 保留版本4.0.4,并使用 fetch 方法.请查看此GitHub问题,以获取更改列表.
  • 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屋!

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