In the previous post, we developed a Spring Boot Web Application(User Management System) with Thyemeleaf, HTML, Spring Data JPA, Maven and MySql Database. Also Implement the Pagination In the Application
Here in this we are going to implement sorting concept in this Web Application.
What is in this article ?
- We sort data in Ascending and in Descending order.
- Perform sorting task in all given field name.
Code Implementation
- To Use Pagination, dao class must have to extend the PagingAndSortingRepository interface, this interface have some methods which helps to implement the pagination concept (You can check the link).
- JpaRepository interface also extends the PagingAndSortingRepository interface, so if our dao interface implements the JpaRepository interface then no need to implement the PagingAndSortingRepository interface, but in this article we are going change PagingAndSortingRepository interface to JpaRepository interface.