#Filter with pagination in Spring
5 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @humble copper! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
spring's pagination is different from completely generic relational database condition filtering, since spring's pages can be used in more situations than just relational databases. Therefore, you should use JPA's criteria API to dynamically build a query according to your user's filters. See here: https://docs.spring.io/spring-data/jpa/reference/jpa/specifications.html
essentially, you can make your repository extend JpaSpecificationExecutor<EntityType> and then you get access to Page<EntityType> findAll(Specification<EntityType>, Pageable);