title: mapstruct: update existing field of entity using data from DTO
body: <p>I recently added mapStruct in my project. This framework is cool, but I can not figure out one thing.</p>
  
  <p>This is my case: I have <code>Profile</code> entity and field with the <code>Person</code> type. I want to update it using <code>ProfileDto</code>. I am using <code>void fromDto(ProfileDto dto, @MappingTarget Profile entity)</code> method for this. The problem is that mapper always <strong>create new Person</strong> instead of using person from <code>profile</code> entity</p>
  
  <p>My entity is:</p>
  
  <pre><code>public class Profile  {
      private Person person;
      .. setters, getters and  constructors 
  }
  
  public class Person extends AbstractEntity {
      private String name;
      private String surname;
      .. setters, getters and  constructors 
  }
  </code></pre>
  
  <p>Dto </p>
  
  <pre><code>public class ProfileDto  extends AbstractDto {
      private String name;
      private String surname;
      .. setters, getters and  constructors 
  }
  </code></pre>
  
  <p>my mapper</p>
  
  <pre><code>public abstract class ProfileMapper {
  
      @Mappings({
              @Mapping(target = "name", source = "entity.person.name"),
              @Mapping(target = "surname", source = "entity.person.surname")
  
      })
      public abstract ProfileDto toDto(Profile entity);
  
      @InheritInverseConfiguration(name = "toDto")
      public abstract void fromDto(ProfileDto dto, @MappingTarget Profile entity);
  }
  </code></pre>
  
  <p>generated code</p>
  
  <pre><code>      @Override
          public void fromDto(ProfileDto dto, Profile entity) {
              if ( dto == null ) {
                  return;
              }
              Person person = new Person();
              entity.setPerson( person );
  ...
  </code></pre>
  
  <p>I don't need to create new instance of person here</p>
  
  <p><strong>person = new Person();</strong> </p>
  
  <p>I what somehow to replace this string with:</p>
  
  <p><strong>person = entity.getPerson()</strong> </p>