title: Mapstruct : Map Object in List to Object
body: <p>I am trying to map Entity object into DTO to transfer to the frontend app.
  Query returns List which contains institutionName and internalName and i want to map them to List of modelsInstitution and modelsInternalName in DTO.
  I am stuck with my mappers class.</p>
  
  <p>Below is my Entity:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Entity
  @DynamoDBTable(tableName = "Inventory")
  public class Inventory 
  {
      @Id
      private String id;
      private String institutionName;
      private String internalName;
      private String lanAdapter;
  
      public Inventory() {
      }
  
      public Inventory(String Id,String InstitutionName, String LanAdapter, String InternalName) 
      {
          this.id = Id
          this.lanAdapter = LanAdapter;
          this.institutionName = InstitutionName;
          this.internalName = InternalName;
  
      }
  
      @DynamoDBHashKey(attributeName = "Id")
      public String getId() 
      {
          return id;
      }
      public void setId(String id) 
      {
          this.id=id;
      }
  
      @DynamoDBAttribute(attributeName = "InstitutionName")
      public String getInstitutionName()
      {
          return institutionName;
      }
      public void setInstitutionName(String InstitutionName)
      {
          this.institutionName = InstitutionName;
      }
  
      @DynamoDBAttribute(attributeName = "LanAdapter")
      public String getLanAdapter()
      {
          return lanAdapter;
      }
      public void setLanAdapter(String LanAdapter)
      {
          this.lanAdapter = LanAdapter;
      }
  
          @DynamoDBAttribute(attributeName = "InternalName")
      public String getInternalName()
      {
          return internalName;
      }
      public void setInternalName(String InternalName)
      {
          this.internalName = InternalName;
      }
  }
  </code></pre>
  
  <p>Below is my DTO Object:</p>
  
  <pre class="lang-java prettyprint-override"><code>public class FilterDto 
  {
      private List&lt;String&gt; modelsInstitution;
      private List&lt;String&gt; modelsInternalName;
  
      public FilterDto(List&lt;String&gt; modelsInstitution, List&lt;String&gt; versions) {
          super();
          this.modelsInstitution = modelsInstitution;
          this.modelsInternalName = modelsInternalName;
      }
  
      public List&lt;String&gt; getModelInstitution() {
          return modelsInstitution;
      }
      public void setModelInstitution(List&lt;String&gt; modelsInstitution) {
          this.modelsInstitution = modelsInstitution;
      }
      public List&lt;String&gt; getModelInternalName() {
          return modelsInternalName;
      }
      public void setModelInternalName(List&lt;String&gt; modelsInternalName) {
          this.modelsInternalName = modelsInternalName;
      }
  }
  </code></pre>
  
  <p>Mapper Class:</p>
  
  <p>My mapping is not correct, i am missing how to map Entity in List to DTO.</p>
  
  <pre class="lang-java prettyprint-override"><code>@IterableMapping(elementTargetType = Inventory.class)
  @Mappings({
      @Mapping(target="modelsInstitution", expression="java(inventory.getInstitution())"),
      @Mapping(target="modelsInternalName", expression="java(inventory.getInternalName())")
  })
  FilterDto InventoryToFilterDTO1(List&lt;Inventory&gt; inventory);
  </code></pre>