Controlling Result Reach in Hibernate with setMaxResults and setFirstResult
When you need to page through database results in a Java persistence layer, setMaxResults and setFirstResult give you portable control—but version differences and offset pitfalls can trip you up.