Reputation: 1822
Im using Spring Data together with QueryDSL as outlined by Gierke in his blog posts. Everything is working and is relatively simple to implement, but Ive now reached a point where I have a dataview which needs both paging AND sorting. It seems though, that one has to choose on or the other. Why is this? And is there really no way to get both? We have already made considerable investments in time and effort to implement everything this far, would be a shame to get stuck at such a seemingly simple task.
To put it shortly, I need to make a method that takes QueryDSL predicates, a pageable and and some form of sort object to deliver filtered, paged and sorted results.
Any info would be greatly appreciated.
Upvotes: 2
Views: 3179
Reputation: 83171
PageRequest
has a constructor PageRequest(int page, int size, Sort sort)
so to combine both simply pipe your sort options into the PageRequest
instance and hand this to into PagingAndSortRepository
or the relevant methods in QueryDslSpecificationExcutor
.
Upvotes: 5