I would like to implement pagination in my Servlet / EJB / JPA-Hibernate project, but I cannot figure out how only one page is from the request and know the number of pages that I have to display
I use
setFirstResult(int first) ;
setMaxResults(int max) ;
and this works fine, but how can I find out how many pages I will have in total?
(Hibernate is my JPA provider, but I would prefer to use only JPA if possible)
UPDATE: COUNT () seems like the best / easiest solution; but what can be the cost SELECT COUNT(*) FROM ...compared to
executeQuery("SELECT * FROM ...).getListResult().size()?
Kevin source
share