title: NHibernate New item added to bag collection does not get saved when updating parent entity
body: <p>I'm using NHibernate version 3.1.0.4000 with hbm mapping files.
  When I have an entity which contains a bag collection and i save the entity with all the items added to the bag then it saves all the collection items fine. However, when i then subsequently (after the initial save) add another item to the collection and save the entity then it does not save the new item in the collection. I had a look at the SQL being generated by NHibernate and it creates the initial Insert SQL statement, but it does not create the Update SQL statement to update the foreign key value. This issue occurs for all bags in the solution.</p>
  
  <p>Here is a mapping extract:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
                     default-lazy="false"
                     namespace="some_namespace"
                     assembly="some_assembly"&gt;
  
    &lt;class name="Landing"
              table="[Landing]"
              select-before-update="true"
              optimistic-lock="version"&gt;
      &lt;id name="Id"
          column="[Id]"
          unsaved-value="null"&gt;
        &lt;generator class="assigned" /&gt;
      &lt;/id&gt;
  
      &lt;version name="Version"
              column="[Version]"
              unsaved-value="null" /&gt;
  
      &lt;bag name="LandingPermits"
           cascade="all-delete-orphan"
           access="field.camelcase"&gt;
        &lt;key column="[LandingId]" /&gt;
        &lt;one-to-many class="LandingPermit" /&gt;
      &lt;/bag&gt;
  
    &lt;/class&gt;
  &lt;/hibernate-mapping&gt;
  </code></pre>
  
  <p>Here's the Save method on my NHibernate Repository:</p>
  
  <pre><code>    public NHibernateRepository(ISessionFactory factory, string queriesAssemblyName = null, string clientName = null)
  {
      this.sessionFactory = factory;
      this.queriesAssemblyName = queriesAssemblyName;
      this.clientName = clientName;
  
      if (!string.IsNullOrEmpty(this.queriesAssemblyName))
          LoadQueries();
  }
  
  public virtual void Save(IAggregateRoot entity)
  {
      Save(new IAggregateRoot[] { entity });
  }
  
  public virtual void Save(IAggregateRoot[] entities)
  {
      try
      {
          using (var session = OpenSession())
          {
              using (var transaction = session.BeginTransaction())
              {
                  try
                  {
                      foreach (var entity in entities)
                      {
                          if (entity.IsNew)
                              entity.AddedDateTime = DateTime.Now;
                          else
                              entity.UpdatedDateTime = DateTime.Now;
  
                          session.SaveOrUpdate(entity.GetType().Name, entity);
                      }
                      transaction.Commit();
                  }
                  catch (Exception e)
                  {
                      transaction.Rollback();
                      throw e;
                  }
                  finally
                  {
                      if (session.Connection.State == ConnectionState.Open)
                          session.Connection.Close();
  
                      session.Connection.Dispose();
                      session.Close();
                  }
              }
          }
      }
      catch (GenericADOException e)
      {
          var sqlException = e.InnerException as SqlException;
  
          if ((sqlException != null) &amp;&amp; (sqlException.Number == ForeignKeyExceptionNumber))
              throw new EntityInUseException("Save", sqlException);
          else
              throw new RepositoryException("Save", e.InnerException);
      }
      catch (StaleObjectStateException e)
      {
          throw new ConcurrencyException("Save", e, new Identity((Guid?)e.Identifier));
      }
      catch (Exception e)
      {
          throw new RepositoryException("Save", e);
      }
  }
  </code></pre>
  
  <p>I have tried a few things, including setting the inverse property to true, but no success.
  Hope this is enough information for anyone to asssist.
  Thanks</p>