Monday, October 03, 2005

Hibernate: reusing the Criteria object used to count the records

criteria.setProjection(null);
criteria.setResultTransformer(Criteria.ROOT_ENTITY);

Then you can reuse the Criteria object. I use it to count all the records, then I reuse it to perform the query, limiting the number of results (setMaxResults) and the start index (setFirstResult).
Post a Comment