Points To Remember

  • Offset may be required to do pagination or get the results after a particular result from the database.
  • Using offset you can define the first result to be included in the result set from the database. 
  • You can use setFirstResult on the CriteriaQuery to set the first result that you want.

Using offset to get the results

public List<Person> getCategories(Integer offset){
return getSession()
This is how you can set the first result you want to fetch from the database. In this example we have set the first result and the maximum number of records that we need to fetch.