How to use Spring Page without spring data

advertisements

Hi i'm using below code for find article using spring with plain hibernate.

public List<Article>  getArticles(int currPosition, int pageSize) {
        Criteria c = getSession().createCriteria(Article.class);
        c.addOrder(Order.desc("createdDate"));
        c.setFirstResult(currPosition);
        c.setMaxResults(pageSize);
        List<Article> result = c.list();
        return result;
    }

i'm not using spring data in my project now, So how can i use org.springframework.data.domain.Page with my project.

Page<Person> persons = personService.findAllPageable(new PageRequest(evalPage, evalPageSize));


You can use Pageable#getSize to set maxResults, Pageable#getOffset for setFirstResult and Pageable#getSort to obtain sorting parameters.