Skip to content

Commit

Permalink
Merge pull request #758 from darxriggs/getTotalCount-and-sorting-7.3.x
Browse files Browse the repository at this point in the history
Fix getTotalCount() with Hibernate for sorting parameters (7.3.x backport)
  • Loading branch information
puneetbehl committed Oct 6, 2023
2 parents 3a0fc2a + 30a79bb commit 86040d5
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public int getTotalCount() {
if (totalCount == Integer.MIN_VALUE) {
totalCount = hibernateTemplate.execute(new GrailsHibernateTemplate.HibernateCallback<Integer>() {
public Integer doInHibernate(Session session) throws HibernateException, SQLException {
final CriteriaQuery finalQuery = criteriaQuery.select(criteriaBuilder.count(queryRoot)).distinct(true);
final CriteriaQuery finalQuery = criteriaQuery.select(criteriaBuilder.count(queryRoot)).distinct(true).orderBy();
final Query query = session.createQuery(finalQuery);
hibernateTemplate.applySettings(query);
return ((Number)query.uniqueResult()).intValue();
Expand Down

0 comments on commit 86040d5

Please sign in to comment.