How to retrieve rows from the middle of the table in mysql using hibernate?


I have to display rows from the database table on the UI. So, lets say we have 200 rows in the table. So , my first hit will give me first 20 rows. Now, i want to fetch next 20 rows in the next hit. I am using Hibernate for handling database CRUD operations.

query.setMaxResults(int size) works fine for first hit .But how to handle transactions for 2nd and onwards hits ?


  • a particular page of the result set may be selected by calling setMaxResults(), setFirstResult().