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
SampleDAO.java
@SuppressWarnings("unchecked")
public List<Person> getCategories(Integer offset){
return getSession()
.createCriteria(Person.class)
.setFirstResult(offset!=null?offset:0)
.setMaxResults(10)
.list();
}
Comments
Post a Comment