javahibernatepaginationscrollableresults

Hibernate - best pagination method


I'm working on a website where I have to show news vertically (one after another). Let's says I have like 100 news and I want to show 10 by 10 just by scrolling. I don't want to remove the first 10 news I've shown, just keep scrolling and adding more news. I've been looking for the right pagination method and I don't know if ScrollableResults is the best option for this case or I should go for another option.

This is not a common grid where you move forward ad backward, it is just scrolling down to see more news.

btw I'm using extjs for the client.

Thanks,

PS: I've been looking at this site


Solution

  • You can do something like this.Its in java.But you can relate it with your case.

    query.setFirstResult((searchCriteria.getPageNumber()-1)*searchCriteria.getItemsPerPage());
    query.setMaxResults(searchCriteria.getItemsPerPage());
    

    where query is org.hibernate.Query object. ItemsPerPage is 10 in your case. PageNumber you will send from front end as you scroll. Hope it helps.