The largest Interview Solution Library on the web


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

S.N.Method & Description
1public Criteria setFirstResult(int firstResult)This method takes an integer that represents the first row in your result set, starting with row 0.
2public Criteria setMaxResults(int maxResults)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:

Criteria cr =session.createCriteria(Employee.class);
cr.setFirstResult(1);
cr.setMaxResults(10);
List results =cr.list();
« Previous | 1 | 2 | 3 | Next »


copyright © 2014 - all rights riserved by javatechnologycenter.com