title: Mapstruct many-to-one mapping
body: <p>I have a question about @ManyToOne mapping in the mapstruct. I have two tables</p>
  
  <p>The first one:</p>
  
  <pre><code>@Entity
  @Table(name = "members", schema = vsm)
  public class MemberEntity{
  
      @Column(name = "id", nullable = false)
      protected Long id;
  
      @ManyToOne(optional = false)
      @JoinColumn(name = "case_id", nullable = false)
      private CaseEntity case;
  }
  </code></pre>
  
  <p>And the second one:</p>
  
  <pre><code>@Entity
  @Table(name = "cases", schema = vsm)
  public class CaseEntity {
  
      @Column(name = "id", nullable = false)
      protected Long id;
  
      @Column(name = "description", nullable = false)
      protected String description;
  }
  </code></pre>
  
  <p>And I have a cases dto like this:</p>
  
  <pre><code>public class CasesDto{
  
      protected Long id;
  
      protected String description;
  
      private List&lt;MemberDto&gt; members;
  }
  </code></pre>
  
  <p>And MemberDto the same as entity.</p>
  
  <p>I need to make a mapping with mapstruct like this:</p>
  
  <pre><code>CasesDto mapToDto(CaseEntity entity);
  </code></pre>
  
  <p>And I need to fill List members; But I can't understand how.</p>