title: Don't change the reference to a collection with cascade="all-delete-orphan"
body: <p>I am getting an error:</p>
  
  <blockquote>
    <p>Don't change the reference to a collection with cascade="all-delete-orphan"</p>
  </blockquote>
  
  <p>while trying the following operation:</p>
  
  <pre><code>beginTx();
  Parent parent = new Parent();
  Child child = new Child();
  parent.addChild(child);
  getSession().save(parent);
  commitTx();
  closeSession();
  
  beginTx();
  //id is the primary key
  child.setID(null);
  getSession().update(child);
  commitTx();
  closeSession();
  </code></pre>
  
  <p>Parent and child are related by <code>one-to-many</code> with cascade = '<code>all-delete-orphan</code>'.</p>
  
  <pre><code>class Parent {
  Set child;
  }
  
  
  &lt;set name="child" table="Child" cascade="all-delete-orphan" inverse="true"&gt;
      &lt;key column="FK"&gt;&lt;/key&gt;
      &lt;one-to-many class="Child"/&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p>Any idea why this exception is being thrown? 
  Why is setting null on the primary key causing this exception even though the entity is in detached state ?</p>