I have a domain object called User:
public class User {
private long id;
private String username;
private String email;
private List<Profile> profiles;
// getters & setters
}
And I have the related DTO (UserDTO) which is
public class UserDTO {
private long id;
private String username;
private String email;
private List<Long> profilesId;
// getters & setters
}
I'd like to use Dozer to convert from domain object to DTO. The Profile class has a property
Long id;
What I want is that Dozer takes the profile's id for each profile in the list and save it in the DTO's list. Can I do something like that? Do I have to use custom converters?
Here's my actual mapping file
<mapping>
<class-a>common.model.User</class-a>
<class-b>common.model.dto.UserDTO</class-b>
<field>
<a>legalEntity.id</a>
<b>legalEntityId</b>
</field>
<field type="one-way">
<a>profiles.id</a>
<b>profilesId</b>
</field>
</mapping>