Think about using the Hibernate Criteria API. It will make your life alot easier, and doing this type of pagination of results will make your life alot easier.
Here's a quick and simple tutorial on the topic of the Hibernate Criteria API, along with lots of Hibernate3 code and exmaples:
http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=09howtousethecriteriaapi
Your queries will be greatly simplified, and you can have more control, programatically, of how many results are returned on a page or resultset:
Code:
public class FindFirstFive {
public static void main(String args[]) {
User user = new User();
Session session = HibernateUtil.beginTransaction();
Criteria criteria = session.createCriteria(User.class);
criteria.setFirstResult(0);
criteria.setMaxResults(5);
List results = criteria.list();
HibernateUtil.commitTransaction();
for (int i = 0; i<results.size(); i++) {
System.out.println(results.get(i).toString());
}
}
}