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?<
The easiest way I could find is to use QueryDSL or Specifications. I prefer QueryDSL.