Skip to content
Advertisement

Design pattern for Java Spring data JPA projects [closed]

This is my current project design
Controller-> service -> Repository

I am trying to understand :

  1. What layer(Name) i can create between Controller-> service if in case i need to have layer which can be composition of services.

  2. What layer I can create between service -> Repository .

  3. If i am having Repository Layer can i also keep DAO layer.

Many Thanks.

Advertisement

Answer

The service layer is the thing you need to use when manipulating with data retrieved from db. So you do not need to create extra-layers between controller-service-repository. The main idea is to use repository for db operations, service for data manipulation + additional logic, controller for creating api. Or there is an approach with additional api layer where you create api interfaces then controller implements them and then service(logic) and repository(sql)

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement