Mysema Querydsl: There's no JPAQuery#list() method

扶醉桌前 提交于 2019-12-04 03:13:05

问题


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.

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.

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>

Why is the JPAQuery#list() method not present?


回答1:


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.

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.


来源:https://stackoverflow.com/questions/33102742/mysema-querydsl-theres-no-jpaquerylist-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!