I am trying to implement pagination in spring mvc.
In my case, I have a Review entity which consists of reviewStatus and the date it was submitted on.
I am trying to use JpaRepository, but I am not sure how to support the following search query using it.
SELECT * from review WHERE review.reviewStatus = 2 AND
( review.submittedOn BETWEEN '2015-09-08' AND '2015-09-09' )
I can see(refer http://docs.spring.io/spring-data/jpa/docs/1.4.3.RELEASE/reference/html/jpa.repositories.html) that we can define methods for particular queries like findbyname.
However, in my case, if the user doesn't provide status then the above query simply becomes:
SELECT * from review WHERE ( review.submittedOn BETWEEN
'2015-09-08' AND '2015-09-09' )
and if there is no submitted date provided, it becomes
SELECT * from review WHERE review.reviewStatus = 2
In short, the query depends upon the values entered by the end-user and I wish to use the same parameters to implement pagination.
Please guide and/or share links to implement same.
Thanks in advance.