Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Query::getResultCount #622

Open
quaff opened this issue Apr 29, 2024 · 0 comments · May be fixed by #660
Open

Introduce Query::getResultCount #622

quaff opened this issue Apr 29, 2024 · 0 comments · May be fixed by #660
Labels
candidate-for-4 Good candidate for JPA 4

Comments

@quaff
Copy link

quaff commented Apr 29, 2024

Hibernate introduce SelectionQuery.getResultCount() since 6.5.0, It's useful for paged query, Query object can be reused for both data and count query.

Query query = entityManager.createQuery(queryString);
query.setFirstResult(10);
query.setMaxResults(10);
result.setTotal(query.getResultCount()); // must ignore `firstResult` and `maxResults`
result.setData(query.getResultList());
@gavinking gavinking added the candidate-for-4 Good candidate for JPA 4 label Aug 25, 2024
gavinking added a commit to gavinking/jpa-api that referenced this issue Sep 20, 2024
see issue jakartaee#622

Signed-off-by: Gavin King <gavin@hibernate.org>
@gavinking gavinking linked a pull request Sep 20, 2024 that will close this issue
@gavinking gavinking linked a pull request Sep 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
candidate-for-4 Good candidate for JPA 4
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants