title: nhibernate many-to-many bag not inserting in the association table
body: <p>I know this has been asked and answered  a number of times, but I have two classes that are many-to-many. I've reciprocal mapped them using bags. Here is the NHibernate Mapping:</p>
  
  <p>Calendar:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!--Generated by NHibernate.Mapping.Attributes on 2009-10-09 18:09:29Z.--&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"&gt;
    &lt;class name="Calendar.Calendar, Calendar" table="Calendars"&gt;
      &lt;id name="CalendarId" column="CalendarId" type="Int32"&gt;
        &lt;generator class="native" /&gt;
      &lt;/id&gt;
      &lt;property name="Name" length="100" /&gt;
      &lt;property name="CalendarStatus" /&gt;
      &lt;property name="CalendarType" type="Calendar.GenericEnumMapper`1[[Calendar.CalendarType, Calendar, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Calendar" length="50" /&gt;
      &lt;property name="RecordCreatedBy" column="CreatedBy" length="50" /&gt;
      &lt;property name="RecordModifiedBy" column="ModifiedBy" length="50" /&gt;
      &lt;property name="CreateDate" /&gt;
      &lt;property name="ModifiedDate" /&gt;
      &lt;bag name="Events" table="CalendarEventsInCalendar" cascade="all"&gt;
        &lt;key column="CalendarId" /&gt;
        &lt;many-to-many class="Calendar.CalendarEvent, Calendar" column="CalendarEventId" /&gt;
      &lt;/bag&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>CalendarEvent:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;!--Generated by NHibernate.Mapping.Attributes on 2009-10-09 18:27:46Z.--&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"&gt;
    &lt;class name="Calendar.CalendarEvent, Calendar" table="CalendarEvents"&gt;
      &lt;id name="CalendarEventId" column="CalendarEventId" type="Int32"&gt;
        &lt;generator class="native" /&gt;
      &lt;/id&gt;
      &lt;property name="EventStatus" /&gt;
      &lt;property name="StartTime" /&gt;
      &lt;property name="EndTime" /&gt;
      &lt;property name="ImageUrl" length="255" /&gt;
      &lt;property name="Description" length="2000" /&gt;
      &lt;property name="LocationName" length="255" /&gt;
      &lt;property name="Address1" length="255" /&gt;
      &lt;property name="Address2" length="255" /&gt;
      &lt;property name="City" length="255" /&gt;
      &lt;property name="State" length="255" /&gt;
      &lt;property name="Zip" length="10" /&gt;
      &lt;property name="Title" length="255" /&gt;
      &lt;property name="Url" length="255" /&gt;
      &lt;property name="ExternalSystemId" /&gt;
      &lt;property name="ExternalSystem" type="Calendar.GenericEnumMapper`1[[Calendar.ExternalSystemType, Calendar, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Calendar" length="50" /&gt;
      &lt;property name="RecordCreatedBy" column="CreatedBy" length="50" /&gt;
      &lt;property name="RecordModifiedBy" column="ModifiedBy" length="50" /&gt;
      &lt;property name="CreateDate" /&gt;
      &lt;property name="ModifiedDate" /&gt;
      &lt;many-to-one name="ParentEvent" column="ParentEventId" /&gt;
      &lt;bag name="ChildEvents" lazy="true" fetch="subselect" cascade="all" inverse="true"&gt;
        &lt;key column="ParentEventId" /&gt;
        &lt;one-to-many class="Calendar.CalendarEvent, Calendar" /&gt;
      &lt;/bag&gt;
      &lt;bag name="Calendars" table="CalendarEventsInCalendar" lazy="false" inverse="true"&gt;
        &lt;key column="CalendarEventId" /&gt;
        &lt;many-to-many class="Calendar.Calendar, Calendar" column="CalendarId" /&gt;
      &lt;/bag&gt;
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>And here's how I add an Event to a Calendar:</p>
  
  <pre><code>    public virtual void AddEvent(CalendarEvent calEvent)
      {
          if(!calEvent.Calendars.Contains(this))
              calEvent.Calendars.Add(this);
  
          Events.Add(calEvent);
      }
  </code></pre>
  
  <p>Then I do a SaveOrUpdate(calendar)</p>
  
  <p>Any ideas?</p>