Skip to content

Commit

Permalink
CCMSPUI-379: Update count query to be more efficient
Browse files Browse the repository at this point in the history
Signed-off-by: Jamie Briggs <jamie.briggs@digital.justice.gov.uk>
  • Loading branch information
Jamie Briggs committed Feb 20, 2025
1 parent 0400762 commit c045010
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void applySortingClause(CriteriaQuery<T> query, Pageable pageable,
private long getCount(Specification<T> specification, CriteriaBuilder criteriaBuilder) {
CriteriaQuery<Long> countQuery = criteriaBuilder.createQuery(Long.class);
Root<T> countRoot = countQuery.from(getEntityClazz());
countQuery.select(criteriaBuilder.count(countRoot));
countQuery.select(criteriaBuilder.count(countRoot.get("id")));
applyWhereClause(countQuery, specification, criteriaBuilder, countRoot);
return entityManager.createQuery(countQuery).getSingleResult();
}
Expand Down

0 comments on commit c045010

Please sign in to comment.