org.hibernate Code Samples
- How do I create Hibernate's SessionFactory?
- How do I limit the Hibernate query result?
- How do I use Hibernate's Restriction.in criterion?
- How do I retrieve a list of Hibernate's persistent objects?
- How do I delete persistent object in Hibernate?
- How do I retrieve object from database in Hibernate?
- How do I store object in Hibernate?
- How do I set the fetch mode for Criteria association?
- How do I use min, max, avg and sum Projections?
- How do I add Restrictions to the Criteria object?
- How do I create a pagination using Criteria?
- How do I count the total records using Projections?
- How do I select a single record using Criteria?
- How do I order the Criteria query resultset?
Page 1 of 2 |
Prev
|
Next
How do I limit the Hibernate query result?
In the example below you'll see how to limit the number of records returned by the Hibernate queries. Limiting the query result usually used from created a pagination result where we can navigate from page to page in our application data but only a few data are read from the database.
In the Hibernate's Query object we need to specify the first result and max results by calling the setFirstResult() and setMaxResults() methods.