title: Hibernate many to many removing entries in join table while update owner table
body: <p>I am trying to update an entity which is having many to many relationship with another table. </p>
  
  <pre><code>           @Entity(name = "coaching")
           public class CoachingEntity {
  
  
  @ManyToMany(fetch = FetchType.LAZY, cascade = { CascadeType.REFRESH })
      @JoinTable(name = "coaching_field", joinColumns = @JoinColumn(name = "coachingId",    referencedColumnName = "coachingId"), inverseJoinColumns = @JoinColumn(name = "fieldId", referencedColumnName = "fieldId"))
     private Set&lt;FieldEntity&gt; fieldEntityList;
  </code></pre>
  
  <p>Now, when I update CoachingEntity, hibernate is removing entries from coaching_field table (many to many join table). I have searched in internet (<a href="https://stackoverflow.com/questions/3504371/jpa-update-many-to-many-deleting-records">JPA update many-to-many deleting records</a>) but I am not able to find the right approach. Even in <a href="https://stackoverflow.com/questions/14897067/jpa-many-to-many-merge-on-the-owner-triggers-delete-on-join-table">JPA many to many merge on the owner triggers delete on join table</a>, I tried his recommended approach where he used set but I am facing the same problem. As per <a href="https://stackoverflow.com/a/1078295/2116229">https://stackoverflow.com/a/1078295/2116229</a>, do I need to override equals and hashcode? </p>