I've been searching for an answer to this problem and found a lot of resources on how to build a REST API that supports pagination, sorting, and filtering, using what are considered best practices by each author. The problem lies in the fact that these best practices seem to be subjective and there isn't a standardized way to implement these features.
The best examples of what I'm looking for are this implementation that makes use of Spring Data and a Gist published by someone who found himself on the same situation. The first solution relies on Spring Data JPA, whereas I'm using vanilla JPA, which would make me change my entire logic. The second example seems a bit crude since the author himself states that it doesn't contemplate HATEOAS and links, which are, from what I've gathered, an important part of a modern pagination for REST APIs.
What I can't seem to find is a "plug-and-play" implementation of these concepts, that can be easily integrated with Jersey, even if it means adapting my JPA logic to use its methods. Surely there are advantages to custom implementations as they can be adapted to each project's specific needs, but they can lead to some pitfalls and end up hurting the API in the long run. It would be really useful to have some kind of annotation that can be injected and parse all the required fields, such as sort, order, page, etc.
Is there a dependency that I can add to my project that doesn't force me to reinvent the wheel?
I'm currently using this configuration that I adapted from the example provided in the question. It's not optimal but it works until I can find a better solution. Hope this helps someone who's in the same situation!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With