title: How to use inheritance with ModelMapper's PropertyMap
body: <p>I have been using the <code>ModelMapper</code> to convert <code>Identity</code> objects (entities) with <code>DTO</code> objects. I want to implement generic property conversions in a generic class for all entities (<code>GenericEToDtoPropertyMap</code>) and explicit property conversions in separate child-classes for each entity (<code>PersonEToDTOPropertyMap</code> for entity <code>Person</code>). To make it more clear, this is my code:</p>
  
  <p>Generic property map:</p>
  
  <pre><code>public class GenericEToDtoPropertyMap&lt;E extends Identity, DTO extends PersistentObjectDTO&gt; extends PropertyMap&lt;E, DTO&gt; {
  
    @Override
    protected void configure() {
      // E.oid to DTO.id conversion
      map().setId(source.getOid());
    }
  
  }
  </code></pre>
  
  <p>Specific property map for entity Person:</p>
  
  <pre><code>public class PersonEToDTOPropertyMap extends GenericEToDtoPropertyMap&lt;Person, PersonDTO&gt; {
  
    @Override
    protected void configure() {
      super.configure();
      // implement explicit conversions here
    }
  
  }
  </code></pre>
  
  <p>Usage of property map:</p>
  
  <pre><code>modelMapper = new ModelMapper();
  Configuration configuration = modelMapper.getConfiguration();
  configuration.setMatchingStrategy(MatchingStrategies.STRICT);
  modelMapper.addMappings(new PersonEToDTOPropertyMap());
  // convert person object
  PersonDTO personDto = modelMapper.map(person);
  </code></pre>
  
  <p>The problem is that the generic conversions do not apply. In my case <code>person.oid</code> does not get copied to <code>personDto.id</code>. It works correctly only if I remove the part:</p>
  
  <pre><code>map().setId(source.getOid());
  </code></pre>
  
  <p>from the <code>GenericEToDtoPropertyMap.configure()</code> method and put it in the <code>PersonEToDTOPropertyMap.configure()</code> method.</p>
  
  <p>I guess, it has something to do with <code>ModelMapper</code> using <code>Reflection</code> to implement the mappings, but it would be nice if I could use inheritance in my property maps. Do you have any idea how to do this?</p>