I'm trying to use a mapstruct and I need to mapping Entity
with a sub Entity
list, I have relationship oneToMany
and manyToOne
and I need to mapping in both cases:
@Data
@Entity
public class EmailEntity {
private int id;
... // some fields
@ManyToOne
private DeliveredEmailInfoEntity deliveredEmailInfo;
}
.
@Data
@Entity
public class DeliveredEmailInfoEntity {
private int id;
... // some fields
@OneToMany
private List<EmailEntity> emails;
}
mapping to:
@Data
public class EmailDTO {
private int id;
... // some fields
private DeliveredEmailInfoDTO deliveredEmailInfo;
}
.
@Data
public class DeliveredEmailInfoDTO {
private int id;
... // some fields
private List<EmailDTO> emails;
}
How to do it in the best way ?