I am trying to use MapStruct for a structure similar to the following:
@Data
public class ClassAEntity {
private int id;
private String name;
private String numT;
private List<ClassBEntity) bs;
}
@Data
public class ClassBEntity {
private int id;
private String name;
private String numT;
private List<Other> oc;
}
@Data
public class ClassA {
private int id;
private String name;
private List<ClassB) bs;
}
@Data
public class ClassB {
private int id;
private String name;
private List<Other> oc;
}
In the interface I have added the following mapping:
ClassAEntity map(ClassA classA, String numT)
I get a warning because it can't map numT to classBEntity.numT and I can't add it with @Mapping in the following way:
@Mapping(source = "numT", target = "bs[].numT")
On the other hand I need to ignore the parameter oc of classBEntity because "Other" object contains classAEntity and forms a cyclic object. (because I use oneToMany JPA). I have tried the following:
@Mapping(target = "bs[].oc", ignore = true)
Thank you for your help