Best way to implement pagination with spring MVC with mysql

I have more than 100,000 records in my database, and in the future it may be more. So I want to implement pagination for this. He loves messages, and from time to time the user may switch to old or too old records. I am using spring MVC and the database is mysql.

I also use PagedListHolder to implement pagination. I want to display 25 posts per page, but if I initially download all 100,000 posts, it will take some time to load all the posts. It’s better if I upload 100 entries first and then combine the list with the other 100 entries and so on. And if the user wants to see the oldest message, then pick up the last 100 messages and display the last 25 messages on the last page.

So I just wanted to know how feasible this solution is, if it helps, if someone helps me give the right direction.

+5
source share
1 answer

If you use ORM, Spring Data JPA , you can easily provide the pagination function.

DAO , , PagingAndSortingRepository, : -

public interface BookRepository extends PagingAndSortingRepository<Book,Long>{
      // methods other than plain CRUD can be declared here
}

pagination Pageable. PageRequest , , , , , , .

PageRequest , : -

Page<Book> result = bookRepository.findAll(pageRequest);

Page , , , , , .

tutorial .

+6

All Articles