title: mapstruct mapping Entity OneToMany to DTO and reverse
body: <p>I'm trying to use a <a href="http://mapstruct.org" rel="nofollow noreferrer">mapstruct</a> and I need to mapping <code>Entity</code> with a sub <code>Entity</code> list, I have relationship <code>oneToMany</code> and <code>manyToOne</code> and I need to mapping in both cases:</p>
  
  <pre><code>@Data
  @Entity
  public class EmailEntity {
  
  private int id;  
  
  ... // some fields
  
  @ManyToOne
  private DeliveredEmailInfoEntity deliveredEmailInfo;
  
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>@Data
  @Entity
  public class DeliveredEmailInfoEntity {
  
  private int id;
  
  ... // some fields  
  
  @OneToMany
  private List&lt;EmailEntity&gt; emails;
  
  }
  </code></pre>
  
  <p>mapping to:</p>
  
  <pre><code>@Data
  public class EmailDTO {
  
  private int id;  
  
  ... // some fields
  
  private DeliveredEmailInfoDTO deliveredEmailInfo;
  
  }
  </code></pre>
  
  <p>.</p>
  
  <pre><code>@Data
  public class DeliveredEmailInfoDTO {
  
  private int id;
  
  ... // some fields  
  
  private List&lt;EmailDTO&gt; emails;
  
  }
  </code></pre>
  
  <p>How to do it in the best way ?</p>