I am using JSF and Hibernate combo. Although my database has very few records at present, but it is expected to grow. That is why I prefer the H pagination using setFirstResult and setMaxResults over the pagination in JSF.
In order to construct numbered pages on the UI side, I need to know the total number of records returned by a query. One way to do that is by putting the session result in a List by using the following:
Code:
List list = session.createQuery(query).list();
and then do a count on the list. However, this defeats the purpose as the list is stored in the memory.
Is there a way to find out number of records in a query without executing it through the session? I know it is an oxymoronic questions, I thought I would ask it anyway :-)
Thanks
Rauf