title: Hibernate - @ElementCollection - Strange delete/insert behavior
body: <pre><code>@Entity
  public class Person {
  
      @ElementCollection
      @CollectionTable(name = "PERSON_LOCATIONS", joinColumns = @JoinColumn(name = "PERSON_ID"))
      private List&lt;Location&gt; locations;
  
      [...]
  
  }
  
  @Embeddable
  public class Location {
  
      [...]
  
  }
  </code></pre>
  
  <p>Given the following class structure, when I try to add a new location to the list of Person's Locations, it always results in the following SQL queries:</p>
  
  <pre><code>DELETE FROM PERSON_LOCATIONS WHERE PERSON_ID = :idOfPerson
  </code></pre>
  
  <p>And</p>
  
  <pre><code>A lotsa' inserts into the PERSON_LOCATIONS table
  </code></pre>
  
  <p>Hibernate (3.5.x / JPA 2) deletes all associated records for the given Person and re-inserts all previous records, plus the new one.</p>
  
  <p>I had the idea that the equals/hashcode method on Location would solve the problem, but it didn't change anything.</p>
  
  <p>Any hints are appreciated!</p>