title: Exception in Hibernate (Don't change the reference to a collection with cascade="all-delete-orphan")
body: <p>I am getting a weird problem in hibernate. I am using hibernate and spring in my project.</p>
  
  <p>Problem is I am having a parent child relation, and when I try to update the parent I am getting the exception </p>
  
  <p>Caused by: org.hibernate.HibernateException: Don't change the reference to a collection with cascade="all-delete-orphan"</p>
  
  <p>Following are the mappings :</p>
  
  <p>Parent :</p>
  
  <pre><code>    &lt;set name="kittens" fetch="join" lazy="false"
          inverse="true" cascade="all-delete-orphan"&gt;
          &lt;key&gt;
              &lt;column name="ID" precision="22" scale="0"
                  not-null="true" /&gt;
          &lt;/key&gt;
          &lt;one-to-many
              class="kitten" /&gt;
      &lt;/set&gt;
  </code></pre>
  
  <p>Child :</p>
  
  <pre><code>    &lt;composite-id name="id" class="kittenId"&gt;
           &lt;key-property name="kittenId" type="java.lang.Long"&gt;
              &lt;column name="Kitten_ID" precision="22" scale="0" /&gt;
          &lt;/key-property&gt;
         &lt;key-many-to-one name="cat" class="cat"&gt;
              &lt;column name="ID" precision="22" scale="0" /&gt;
          &lt;/key-many-to-one&gt;                   
      &lt;/composite-id&gt;
  </code></pre>
  
  <p>I found in a forum and tried changing like </p>
  
  <pre><code>public void setKittens(Set kittens) {
      this.kittens.clear(); 
      this.kittens.addAll(kittens); 
  } 
  </code></pre>
  
  <p>But now I am facing </p>
  
  <p>org.hibernate.PropertyAccessException: Exception occurred inside setter of Kittens</p>
  
  <p>Any help will be appreciated pls.</p>