// see https://forum.hibernate.org/viewtopic.php?t=974802
// Save original Projection and ResultTransformer
CriteriaImpl cImpl = (CriteriaImpl) c;
Projection origProjection = cImpl.getProjection();
ResultTransformer origRt = cImpl.getResultTransformer();
// Get total number of records by setting a rowCount projection
page.setMaxRecords(findRowCount(c));
// Restore original Projection and ResultTransformer