title: Unmapped target property with mapstruct while converting an object to a Long
body: <p>I have a problem with mapstruct while converting an object to a Long, I have the following warning:</p>
  
  <p><code>warning: Unmapped target property</code></p>
  
  <p>Here are the entities (I an using Lombok):</p>
  
  <pre class="lang-java prettyprint-override"><code>    @Getter
      @Setter
      @NoArgsConstructor
      @Entity
      public class User {
          ...
          private Set&lt;Address&gt; addresses= new HashSet&lt;&gt;();
          ...
      }
  
      @Getter
      @Setter
      @NoArgsConstructor
      @Entity
      public class Address {
          ...
          private Town town;
          ...
      }
  
      @Getter
      @Setter
      @NoArgsConstructor
      @Entity
      public class Town {
          ...
          private Long id;
          ...
      }
  </code></pre>
  
  <p>and DTOs:</p>
  
  <pre class="lang-java prettyprint-override"><code>    @Getter
      @Setter
      @NoArgsConstructor
      public class UserDTO {
          ...
          private Set&lt;AddressDTO&gt; addresses= new HashSet&lt;&gt;();
          ...
      }
  
      @Getter
      @Setter
      @NoArgsConstructor
      public class AddressDTO {
          ...
          private Long townId;
          ...
      }
  
  </code></pre>
  
  <p>In addressDTO, I want townId instead of the town object. Here are the mappers:</p>
  
  <pre class="lang-java prettyprint-override"><code>@Mapper
  public interface UserMapper {
  
      UserMapper INSTANCE = Mappers.getMapper(UserMapper.class);
  
      UserDTO userToUserDTO(User user);
  
  }
  
  @Mapper
  public interface AddressMapper {
  
      AddressMapper INSTANCE = Mappers.getMapper(AddressMapper.class);
  
      @Mapping(target = "townId", source = "town")
      AddressDTO addressToAddressDTO(Address address);
  
      default Long getTownId(Town town) {
          return town.getId();
      }
  }
  </code></pre>
  
  <p>I wrote a unit test for AddressMapper that works:</p>
  
  <pre class="lang-java prettyprint-override"><code>AddressDTO addressDTO = AddressMapper.INSTANCE.addressToAddresslDTO( address);
  </code></pre>
  
  <p>but it does not work for UserMapper :</p>
  
  <pre class="lang-java prettyprint-override"><code>UserDTO userDTO = userMapper.INSTANCE.userToUserDTO( user);
  </code></pre>
  
  <p>I have the following warning:</p>
  
  <pre><code>warning: Unmapped target property: "townId". Mapping from Collection element "fr.example.myproj.entity.Adress adresses" to "fr.example.myproj.service.dto.AdressDTO adresses".
      UserDTO userToUserDTO(User user);
  </code></pre>