Reputation: 837
I'm developing a web application with Spring MVC, Spring Data JPA and Hibernate, the data access part is taken care of by the repositories provided by Data JPA
However, I'm planning to have a generic service layer (atleast for the common operations), is it a good practise? Or is it advised to not generalise it?
Upvotes: 0
Views: 879
Reputation: 149175
If part of you application will consist of repeating same actions on different objects, it can make sense to have a generic abstract parent class for common operations.
You will have to decide if the gain in de-duplication of code is worth the complexity of the generic. There is no general rule ...
Upvotes: 2
Reputation: 2755
If your app is simple (mostly CRUD) operations then you can access your Repository
classes directly.
If you have additional server-side business logic that needs to be applied to data or if you need to orchestrate multiple data access calls together then adding a Service layer would be appropriate.
Upvotes: 1