The largest Interview Solution Library on the web


Hibernate Tutorials/
« Previous | 1 | 2 | 3 | Next »
There are two methods of the Query interface for pagination.

S.N.Method & Description
1Query setFirstResult(int startPosition)This method takes an integer that represents the first row in your result set, starting with row 0.
2Query setMaxResults(int maxResult)This method tells Hibernate to retrieve a fixed number maxResultsof objects.

Using above two methods together, we can construct a paging component in our web or Swing application. Following is the example which you can extend to fetch 10 rows at a time:

String hql ="FROM Employee";
Query query =session.createQuery(hql);
query.setFirstResult(1);
query.setMaxResults(10);
List results =query.list();
« Previous | 1 | 2 | 3 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com