Good morning
We use the pagination class Page developped by Gavin King and Eric Broyles:
on the links comments page of the web url
http://blog.hibernate.org/cgi-bin/blosx ... ation.html
This Page class uses the fact that an hibernate query can return a scrollable result set,
this is very useful to get the total number of results returned by the query
*without* to do an other query ('select count(*) from ...' ):
****
scrollableResults = query.scroll();
...
//Just retrieve from the database the elements to display in current view page
List resultsToDisplayInCurrentPage = query.setFirstResults(...).setMaxResults(...).list();
...
scrollableResults.last();
//Need to display in the current view page the total number of results returned by the query
totalResultsNumber = getScrollableResults().getRowNumber();
*****
According to the net.sf.hibernate.Criteria API, there is no method Criteria.scroll()
so the equivalent code is not possible to support pagination with Criteria query:
so is there any elegant workaround to get the total number of results with Criteria api
without doing an other query and avoiding to retrieve from the database more elements
than we need to display in the current view page?
thank you for any suggestion
F