JPA - Pagination Query

Use the following query to fetch records based on limit for Pagination using JPA

public List<Employee> getEmpWithPagination(int fromValue,int toValue)
        {
                try{
                       
                return entityManager.createQuery("from Employee", Employee.class).setFirstResult(fromValue).setMaxResults(toValue).getResultList();
                }catch(final Exception e){
                        log.debug("Exception Occured -> "+ExceptionUtils.getFullStackTrace(e));
                        return null;
                }
        }
Technology: 

Search