title: NHibernate many-to-many relationship does not update join-table
body: <p>I'm having trouble saving a many-to-many relationship with nhibernate. I searched and looked at almost every same question in SO and google but nothing works.
  The single classes are update correctly but nothing is inserted in the join-table.</p>
  
  <p>I have 2 classes: Event and Category.</p>
  
  <p>The mapping is this (I updated the two mapping and added some code):</p>
  
  <p>Event:</p>
  
  <pre><code>&lt;bag name="Categories" access="field.camelcase-underscore" table="EventCategories" cascade="all-delete-orphan" lazy="true"&gt;
    &lt;key column="Event"/&gt;
    &lt;many-to-many class="Category" column="Category"/&gt;
  &lt;/bag&gt; 
  </code></pre>
  
  <p>Category:</p>
  
  <pre><code>&lt;bag name="Events" table="EventCategories" access="field.camelcase-underscore"  inverse="true" cascade="all-delete-orphan"  lazy="true" &gt;
    &lt;key column="Category"/&gt;
    &lt;many-to-many class="Event" column="Event"/&gt;
  &lt;/bag&gt;
  </code></pre>
  
  <p>The code who generate the Event+Categories is</p>
  
  <pre><code>public void AddEvent(EventInputModel model)
      {
          var rawCategories = model.Categories.Split(',');
          IEnumerable&lt;Category&gt; categories = _repository.GetCategories(rawCategories);
  
          foreach (var category in rawCategories)
          {
              var c = categories.Where(p =&gt; p.Name.ToLower().Equals(category));
              if (c.Any())
              {
                  model.Event.AddCategory(c.First&lt;Category&gt;());
              }
              else
              {
                  model.Event.AddCategory(new Category() { Name = category });
              }
          }
  
          _repository.Save(model.Event);
  
      }
  
   public void Save(Event p)
      {
          using (var t = Session.BeginTransaction())
          {
              Session.SaveOrUpdate(p);
              t.Commit();
          }
      }
  </code></pre>
  
  <p>I tried to swap every parameter in both mappings but nothing works...</p>
  
  <p>Do you know what I'm doing wrong or have a right mapping for this case?</p>
  
  <p>Thank you very much!</p>