title: Automatically removing associations when deleting entities in NHibernate
body: <p>I have the following entities:</p>
  
  <pre><code>namespace NhLists {
    public class Lesson {
      public virtual int Id { get; set; }
      public virtual string Title { get; set; }
    }
    public class Module {
      public virtual int Id { get; set; }
      public virtual IList&lt;Lesson&gt; Lessons { get; set; }
      public Module() {
        Lessons = new List&lt;Lesson&gt;();
      }
    }
  }
  </code></pre>
  
  <p>And the following mappings:</p>
  
  <pre><code>&lt;class name="Module" table="Modules"&gt;
    &lt;id name="Id"&gt;
      &lt;generator class="identity"/&gt;
    &lt;/id&gt;
    &lt;list name="Lessons" table="ModuleToLesson"
        cascade="save-update"&gt;
      &lt;key column="moduleId"/&gt;
      &lt;index column="position"/&gt;
      &lt;many-to-many 
        column="lessonId" 
        class="NhLists.Lesson, NhLists"/&gt;
    &lt;/list&gt;
  &lt;/class&gt;
  &lt;class name="Lesson" table="Lessons"&gt;
    &lt;id name="Id"&gt;
      &lt;generator class="identity"/&gt;
    &lt;/id&gt;
    &lt;property name="Title"&gt;
      &lt;column name="Title" length="16" not-null="true" /&gt;
    &lt;/property&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>When I delete a lesson by <code>session.Delete(lesson)</code>, is there anyway I can have NHibernate automatically update the association in <code>Module.Lessons</code> to remove the entry from the set? Or am I forced to go through all Modules and look for the lesson and remove that by hand?</p>
  
  <p>Edit: Fixed <code>ICollection</code> and <code>&lt;set&gt;</code> in mappings to <code>IList&lt;&gt;</code> and <code>&lt;list&gt;</code> like I want and tested it.</p>