Using Spring MVC we normally see Controller, Service and Repository layer. The Repository layer uses Entity model which is one to one mapping with database. I thought of following -
This question may have been asked but I could not find. So excuse me for duplicate question.
The entity model used throughout the service layer should be the same. Depending on your architecture and complexity of your application you might want to use different domain models in the service and the controller layer. My recommendation is:
ModelProjector simple maps one model into the other by matching the property names. If they do not match, you can tell it with annotation It is also possible to map complex entity hierarchies onto "flattened" data structures with very straight-forward annotations. The Entity classes remain untouched.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With