Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

maven

querydsl

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?

like image 997
SputNick Avatar asked Oct 13 '15 12:10

SputNick


1 Answers

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.
like image 161
Tunaki Avatar answered Oct 19 '22 12:10

Tunaki