-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Nested target properties uses same method for different mappings #1148
Copy link
Copy link
Closed
Description
It comes from this Stack Overflow question.
In a nutshell:
@Mapper
public interface MyMapper {
@Mappings({
@Mapping(source = "senderId", target = "sender.id"),
@Mapping(source = "recipientId", target = "recipient.id")
})
Entity toEntity(Dto dto);
}Generates:
public class MyMapperImpl implements MyMapper {
@Override
public Entity toEntity(Dto dto) {
if ( dto == null ) {
return null;
}
Entity entity = new Entity();
entity.setRecipient( dtoToClient( dto ) );
entity.setSender( dtoToClient( dto ) );
return entity;
}
protected Client dtoToClient(Dto dto) {
if ( dto == null ) {
return null;
}
Client client = new Client();
client.setId( dto.getRecipientId() );
return client;
}
}It should generate 2 dtoToClient methods instead of one. We most probably need to extend the the PropertyMapping to have the nested name as well and use that somehow in the equals
Reactions are currently unavailable