I am currently Using Spring JPA and utilizing the Sorting and Pagination as described here -
How to query data via Spring data JPA by sort and pageable both out of box?
Now my question is how do I apply a 'where' clause to this?
E.g.
where PRODUCT_NAME='abc';
Just create a query method in your repository interface for this.
Take a look in the docs, here.
Add a query method with paging and where clause.
So you can find User by a property "lastname" and configure Paging settings.
The easiest way I could find is to use QueryDSL or Specifications. I prefer QueryDSL.
To fetch Spring Data JPA apply sorting, pagination along with a where clause check bellow codes
Entity class
Repository class
Service layer to pass where clause using Example object and Pagination+Sorting together using Pagable and Sort Class. We will implement Pageable in controller to inject Sorting logic then will pass that Pagable object to service Layer.
Example<T>
does not take the attribute if its value is null. for that I used Integer id in Entity class as I can set it's value null for first callNow Controller Class