In our application we have multiple layers.
- UI -> This can be JSP/ JSON result of the API
- Controllers -> as in MVC
- Services -> perform single business operation per service
- DAOs -> Data Access Layer (including connection/and DB layer)
And two types of ValueObjects
- FormValueObjects --> More close to View
- Entities --> replica of a row in DB
Since, Entities are DB related, they should not be exposed to other layers.
Since FormValueObjects are not related to DB, they should not be exposed to DAO layer.
I need to populate FormValueObjects from Entities and vice versa. In which layer should this be done? DAO layer/ Services layer or should I create an Adapter layer in between the two?
Please suggest me a good design.