lives
lives

Reputation: 1185

jpa pagination suppress count query

We are using Spring Data JPA Repository. For pagination we are passing the Pageable object to the JPA Repository findBy Methods.

Since in our UI , we are not displaying the total count of records, we don't want the count query to be fired . Is there any way to suppress the count query fired during pagination ?

Upvotes: 7

Views: 6629

Answers (1)

user65839
user65839

Reputation:

Have your repository method return List<Entity> rather than Page<Entity>, and I believe it won't run the count query.

See "Special Parameter Handling" in Spring Data JPA documentation section "1.2.2 Defining query methods".

Upvotes: 7

Related Questions