I am writing simple blog web application using Spring MVC framework. I am willing to add DTO
layer to my app.
I decided to use ModelMapper framework for conversion from Entity
objects to DTO
objects used in my views.
I have just one problem.
On my main page, I am showing a list of posts on my blog. In my view, it's just list of Post
(Entity) objects. I want to change it to pass a list of PostDTO
objects to my view. Is there any way to map List
of Post
objects to List
of PostDTO
object with single method call?
I was thinking about writing converter that will convert this but I am not sure it's a good way to do it.
Also, I am using Lists
of Entities
in few more places like administrative panel or comment below every Post on my page.
Link to code of my app on GitHub repository: repository
@transactional
or follow the link to another answer. – Disparagement