Using MapStruct. Take as example:
class Dto {
DtoA a;
DtoB b;
}
class DtoA {
Long id;
//...
}
class DtoB {
Long id;
//...
}
class Entity {
AB ab;
}
How do I map DtoA and DtoB to AB ?
I tried:
public abstract Entity toEntity(Dto dto);
@Mappings({
@Mapping(source = "a", target = "ab.a"),
@Mapping(source = "b", target = "ab.b")
)}
public abstract AB toABEntity(DtoA a, DtoB b);
Altough code has been generated*, the method toABEntity is not invoked.
*Badly, as it sets first a but then to set b creates a new instance of ab, so a is lost.