title: How to automatically delete many-to-many associations (cascade)
body: <p>In my database I've got Users and UserGroups which have a many-to-many relation. The User has a set of UserGroup, the UserGroup domain object does not see the User.</p>
  
  <pre><code>&lt;class name="User" table="UserTable"&gt;
      &lt;set name="UserGroup" cascade="save-update" access="field.pascalcase-underscore" table="User2UserGroup"&gt;
          &lt;key column="User_Id" /&gt;
          &lt;many-to-many class="UserGroup" column="UserGroup_Id" /&gt;
      &lt;/set&gt;
      ...
  </code></pre>
  
  <p>What I'm trying to achieve is the nhibernate deleting the correlation from the junction table when I delete either a User or a User Group. Additionally User and Group are child objects of, let's call it a Domain. Domain does <code>cascade="all-delete-orphans"</code>, so when a Domain gets deleted it cascade-deletes all its Users and UserGroups.</p>
  
  <p>Back to the User&lt;->UserGroup relation: If I understand correctly I can't use any form of cascade that involves delete as I just want to delete the association between two objects and not the related object itself. (A group shall not vanish, even if it's an orphan. And a User without a group is a valid thing in my world - he just has no rights to do anything at all.)</p>
  
  <p>Do I need to look at events/interceptors? Or can I do what I want to achieve by controlling the mapping?</p>