title: NHibernate 3.2 - Pre and Post Delete event listeners not invoked
body: <p>I am working against an implementation of NHibernate 3.2 with several custom entity state change listeners: PreDelete, Delete, and PostDelete. The DeleteEventListener is defined by inheriting a custom type from DefaultDeleteEventListener, but the others are simply implementing the IEventListener interfaces.</p>
  
  <p>The body of the CustomDeleteEventListener follows:</p>
  
  <pre><code>protected override void DeleteEntity(IEventSource session, object entity, EntityEntry entityEntry, bool isCascadeDeleteEnabled, IEntityPersister persister, ISet transientEntities)
  {
      if (entity is BaseEntity)
          HandleEntityAssociations(session, (BaseEntity)entity);
  
      if (entity is ISoftDeletable) 
      {  
          var e = (ISoftDeletable)entity;
          Utility.SetTrackingInfo(e as BaseModel);
  
          e.Deleted = true; 
  
          CascadeBeforeDelete(session, persister, entity, entityEntry, transientEntities); 
          CascadeAfterDelete(session, persister, entity, transientEntities); 
      } 
      else 
      { 
          base.DeleteEntity(session, entity, entityEntry, isCascadeDeleteEnabled, persister, transientEntities); 
      } 
  }
  </code></pre>
  
  <p>In my tests, I've found that the <code>OnDelete()</code> listener is always called <em>before</em> the <code>OnPreDelete()</code> and <code>OnPostDelete()</code> listeners, and the Pre and Post listeners will never fire if <code>base.DeleteEntity()</code> is not called. This doesn't make any sense to me- I would expect the order to be: <code>OnPreDelete()</code>, <code>OnDelete()</code>, <code>OnPostDelete()</code>. </p>
  
  <p>When I examined the callstack, I noticed that <code>OnDeleteEvent()</code> is triggered by an underlying call to <code>FireDelete()</code> invoked immediately after a call to <code>ISession.Delete()</code>, but <code>OnPreDeleteEvent()</code> is fired by a listener to <code>OnFlush()</code>- completely disconnected from the call to <code>OnDeleteEvent()</code>.</p>
  
  <p>There is almost no documentation for these listeners, only a handful of blogs using them for this-and-that. Does anyone know how these work in NHibernate 3.2, and why I am seeing the behaviors that I am?</p>