title: ModelMapper mapping the wrong id
body: <p>I have an issue while mapping a dto to an entity with nested objects.
  Basically a &quot;DayEntry&quot; cotains many &quot;SingleEntry&quot; and each &quot;SingleEntry&quot; has a &quot;Category&quot;.
  Here are my entities :</p>
  <pre><code>@Entity
  public @Data class SingleEntry {
  
      @Id
      @GeneratedValue(strategy= GenerationType.IDENTITY)
      private Integer id ;
      private float value ;
      private boolean isInEntry= true;
      @ManyToOne
      @JoinColumn(nullable=false)
      private Category category;
      @ManyToOne
      @JoinColumn(nullable=false)
      private DayEntry dayEntry;
  }
  </code></pre>
  <pre><code>@Entity
  public @Data class Category {
  
      @Id
      @GeneratedValue(strategy= GenerationType.IDENTITY)
      private Integer id;
      @Column(unique = true)
      private String name;
      private String color =&quot;cc8282&quot;;
      @OneToMany(mappedBy = &quot;category&quot;)
      //@JsonManagedReference
      private List&lt;SingleEntry&gt; singleEntryList;
  }
  </code></pre>
  <pre><code>@Entity
  public @Data class DayEntry {
  
      @Id
      @GeneratedValue(strategy= GenerationType.IDENTITY)
      private Integer id;
      @Column(nullable = false)
      private LocalDate date;
      @OneToMany(mappedBy = &quot;dayEntry&quot;, cascade = CascadeType.ALL, fetch = FetchType.EAGER)
      private List&lt;SingleEntry&gt; singleEntryList;
  
  }
  </code></pre>
  <p>And this is the Dto i'm using :</p>
  <pre><code>public @Data class SingleEntryForCreationDto {
  
      private float value ;
      private boolean isInEntry;
      private int categoryId;
      private int dayEntryId;
  }
  </code></pre>
  <p>I'm trying to create a new &quot;SingleEntity&quot; so that's why i have no &quot;id&quot; in the dto as it's going to be generated, but when i use model mapper :</p>
  <pre><code>modelMapper.map(singleEntryForCreationDto, SingleEntry.class)
  </code></pre>
  <p>it maps the &quot;categoryId&quot; to the &quot;id&quot; field of the entity &quot;SingleEntry&quot; like you can see in this example of logs :</p>
  <pre><code>********* dto == SingleEntryForCreationDto(value=50.0, isInEntry=false, categoryId=2, dayEntryId=1)
  
  ********* mapped dto == SingleEntry(id=2, value=50.0, isInEntry=false, category=Category(id=2, name=null, color=cc8282, singleEntryList=null), dayEntry=DayEntry(id=1, date=null, singleEntryList=null))
  </code></pre>
  <p>I looked at the documentation of Modelmapper and tried to change the NamingConventions and Transormation configuration but it didn't help. I must be missing something and i surely don't understand how Modelmapper really works as i couldn't fix it on my own.</p>
  <p>I'd appreciate any help or suggestions.</p>
  <p>******EDIT :
  I still don't understand why it mapped categoryId (SingleEntryForCreationDto) to id (SingleEntry). I resolved it this way for now</p>
  <pre><code>modelMapper.typeMap(SingleEntryForCreationDto.class,SingleEntry.class).addMappings(mapper -&gt; mapper.skip(SingleEntry::setId));
  </code></pre>