Reputation: 1097
I want to know the best practices. Following things are confusing:
1) Should model
return an Entity or directly a DTO by using select new ExampleDto(...)
?
2) How we should convert Entity to DTO or vise versa?
3) Can we use the DTO for Entity to DTO conversion that implements serializable
class to convert object injson
etc?
Kindly provide your expert opinion, in whatever direction you want.
Upvotes: 0
Views: 498
Reputation: 971
Many may argue upon what to return in model.In my opinion returning dto is good practice. The reason being-
You may consider using Dozer for conversion from DTO to Entity and vice versa. http://dozer.sourceforge.net/
Upvotes: 1