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.

Filed in: Hibernate Core
© 2014 Java Examples - Built with love by Wayan Saryada.