title: Forcing NHibernate to cascade delete before inserts
body: <p>I have a parent object which has a one-to-many relationship with an <code>ISet</code> of child objects. The child objects have a unique constraint (<code>PageNum</code> and <code>ContentID</code> - the foreign key to the parent).</p>
  
  <pre><code>&lt;set name="Pages" inverse="true" cascade="all-delete-orphan" access="field.camelcase-underscore"&gt;
      &lt;key column="ContentId" /&gt;
      &lt;one-to-many class="DeveloperFusion.Domain.Entities.ContentPage, DeveloperFusion.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /&gt;
  &lt;/set&gt;
  </code></pre>
  
  <p>The problem I've hit is if I remove a <code>ContentPage</code> element from the parent collection, and then add a new one with the same unique key within the same transaction... You get a unique constraint violation because <a href="http://en.wikipedia.org/wiki/NHibernate" rel="noreferrer">NHibernate</a> attempts to perform the insert <em>before</em> the delete.</p>
  
  <p>Is there a way to force NHibernate to perform the delete first?</p>