Conversion of DTO to entity and vice-versa

前端 未结 6 1170

I am using Spring MVC architecture with JPA in my web application. Where to convert data transfer object (DTO) to JPA entity and vice-versa, manua

6条回答
  •  庸人自扰
    2020-12-25 12:18

    In my opinion

    • the Entity -> DTO conversion should be done in the Controller before dispatching the jsp page
    • the DTO -> Entity conversion should be done in the Controller as well after validating the DTO returned from the jsp page

    Its gives you more control over the process and you do not have to change the service/persistence classes every time some logic populating the Entity is changed.

提交回复
热议问题