title: NHibernate.ObjectDeletedException
body: <p>I need some help figuring out how to proceed. I'm building an app to manage a record collection and i have the following mappings.</p>
  
  <pre><code>&lt;class name="Soulful.Core.Domain.Model.Record,Soulful.Core" table="Record"&gt;
      &lt;id name="Id" type="Int32" unsaved-value="0"&gt;
          &lt;generator class="native" /&gt;
      &lt;/id&gt;
  
      &lt;many-to-one name="Artist" class="Soulful.Core.Domain.Model.Artist,Soulful.Core" foreign-key="FK_Artist_Id" cascade="all"&gt;
          &lt;column name="ArtistId" not-null="true" /&gt;
      &lt;/many-to-one&gt;
  
      .... more properties
  &lt;/class&gt;
  
  &lt;class name="Soulful.Core.Domain.Model.Artist,Soulful.Core" table="Artist"&gt;
      &lt;id name="Id" type="Int32" unsaved-value="0"&gt;
          &lt;generator class="native" /&gt;
      &lt;/id&gt;
  
      &lt;property name="Name" type="string" not-null="true" /&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>I want many records to map to one artist and this works just fine. But I run into trouble when I'm trying to delete a record. What I would like to do is:</p>
  
  <p>Delete the record and the artist if no other records are connected to that artist. If there are records connected to the artist, just delete the record.</p>
  
  <p>With the current mapping I get the following error when I call session.Delete(record);:</p>
  
  <pre><code>NHibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)[Soulful.Core.Domain.Model.Artist#3]
  </code></pre>
  
  <p>Here's what my DeleteMethod looks like:</p>
  
  <pre><code>public virtual void Delete(T entity)
  {
      using (var session = GetSession())
      using (var transaction = session.BeginTransaction())
      {
          try
          {
              session.Delete(entity);
              transaction.Commit();
          }
          catch (HibernateException)
          {
              transaction.Rollback();
              throw;
          }
      }
  }
  </code></pre>
  
  <p>What would I need to do to have it working the way I want it to?
  Please feel free to state obvious.</p>
  
  <p><strong>Update</strong>
  I guess I'm asking if I need to handle deletion of artists manually?</p>