Chapter 4. Adding Custom Functionality to JPA Repositories

We have learned how we can manage our entities and create database queries with Spring Data JPA. We have also learned how we can sort and paginate query results. However, if we take a purist architectural point of view, we notice that the described solutions are not following the separation of concerns principle. In fact, our service layer contains code that reveals the inner workings of our repository layer.

This is a trade off between architectural purity and productivity. As always, this choice has some consequences. If we have to migrate our application away from Spring Data JPA, we have to make changes to both the service and repository layer. However, how many times have we heard ...

Get Spring Data now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.