Found this wiki page to do pagination:
http://raibledesigns.com/wiki/Wiki.jsp? ... Pagination
Query q = s.createFilter( collection, "" ); // the trivial filter
q.setMaxResults(PAGE_SIZE);
q.setFirstResult(PAGE_SIZE * pageNumber);
q.setProjection( Projections.alias( Projections.rowCount(), "numResults" ) )
List page = q.list();
The example is certainly not complete. How can I get the "numResults" out of the result? Is this one DB query or two.
The hibernate documentation also mentioned pagination:
http://www.hibernate.org/hib_docs/v3/re ... pagination
However, nothing about total result count.
Basically, what I need is two things:
1. list of the items on the page
2. total result count
Found several solutions, but none gave a complete answer. I know I should use query/criteria with projection. Please help.
I am using Hibernate 3.05