Thanks Will.  I see what I can find and post anything interesting back
here for future reference.

On Oct 13, 4:50 pm, "Will Shaver" <[EMAIL PROTECTED]> wrote:
> I haven't needed to do that, so I don't have a quick answer for you. At some
> level NH has to determine this, so see if you can figure out how this works.
>
> On Mon, Oct 13, 2008 at 1:56 AM, Oz <[EMAIL PROTECTED]> wrote:
>
> > Thanks for the response Will.
>
> > I see the problem now.  In your example, you attach the listener to
> > the Save event and also to the SaveOrUpdate event.
>
> > In my code I attach one listener to the Save event and another
> > listener to the Update event (NOTE - nothing attached to
> > SaveOrUpdate).  It seems that in this case the Save isn't called all
> > the way down the tree in the domain.
>
> > I tried changing my code to the same way as yours and it works,
> > however I need to have separate behaviours depending on whether a save
> > or update is happening.  Is there a way of determining if we're doing
> > a save or an update when the SaveOrUpdate event fires?
>
> > On Oct 10, 6:28 pm, "Will Shaver" <[EMAIL PROTECTED]> wrote:
> > > I just double-checked and I am getting my event listener to pick up
> > > both parent and children for my domain.
>
> > > Be sure you're overriding both:
>
> > > configuration.EventListeners.SaveEventListeners = new
> > > ISaveOrUpdateEventListener[] { listener };
> > > configuration.EventListeners.SaveOrUpdateEventListeners = new
> > > ISaveOrUpdateEventListener[] { listener };
>
> > > My collections are mapped with inverse="true" and cascade="all"
>
> >  > On Fri, Oct 10, 2008 at 10:10 AM, Oz <[EMAIL PROTECTED]> wrote:
>
> > > > Hi Will,
>
> > > > Consider this:
>
> > > > I have a class A which implements IAuditable, as discussed in my
> > > > original post, and class A holds a List collection of class B, which
> > > > also implements IAuditable.
>
> > > > When I save class A, the EventListener fires and I am able to set the
> > > > audit information on class A, similar to my original post, however the
> > > > EventListener doesn't then seem to fire when the save cascades down
> > > > into class B.
>
> > > > Do you have any ideas?
>
> > > > Thanks,
>
> > > > Mark
>
> > > > On 6 Oct, 16:06, "Will Shaver" <[EMAIL PROTECTED]> wrote:
> > > >> Could you set a "DeleteMe" column and have the triggers watch for that
> > and
> > > >> then delete the row? The problem is that once you delete something
> > with NH,
> > > >> the entity is no longer persistant, so changes to it are not sent to
> > the db.
>
> > > >> On Mon, Oct 6, 2008 at 5:38 AM, Oz <[EMAIL PROTECTED]> wrote:
>
> > > >> > Dear NHUsers,
>
> > > >> > I read your Gabriel Schenker's soft deletes article (http://
>
> >www.nhforge.org/blogs/nhibernate/archive/2008/09/06/soft-deletes.aspx)
> > > >> > with great interest and it was very useful!  I have a similar but
> > > >> > slightly different requirement which I'm having some trouble
> > > >> > implementing, and I wonder if you're able to offer some advice?
>
> > > >> > I need to actually do a physical delete from a table, but to update
> > > >> > the "ModifiedDate" and "ModifiedBy" fields on the object BEFORE
> > > >> > deletion.  The reason I need to do this is that I have a trigger
> > that
> > > >> > will fire on deletions, and copy the row to a history table.  I'd
> > like
> > > >> > the row in the history table to reference the actual deletion time
> > and
> > > >> > have the name of the person who deleted it.
>
> > > >> > At the moment, the code I have is as follows, although I have tried
> > > >> > various different options.
>
> > > >> >        protected override void
> > > >> > DeleteEntity(NHibernate.Event.IEventSource session, object entity,
> > > >> >            NHibernate.Engine.EntityEntry entityEntry, bool
> > > >> > isCascadeDeleteEnabled,
> > > >> >            NHibernate.Persister.Entity.IEntityPersister persister,
> > > >> > Iesi.Collections.ISet transientEntities)
> > > >> >        {
> > > >> >            IAuditable auditable = entity as IAuditable;
>
> > > >> >            if (auditable != null)
> > > >> >            {
> > > >> >                auditable.ModifiedDate = DateTime.Now;
> > > >> >                auditable.ModifiedBy = "mark";
>
> > > >> >                CascadeBeforeDelete(session, persister, auditable,
> > > >> > entityEntry, transientEntities);
> > > >> >                base.DeleteEntity(session, auditable, entityEntry,
> > > >> > isCascadeDeleteEnabled, persister, transientEntities);
> > > >> >                CascadeAfterDelete(session, persister, auditable,
> > > >> > transientEntities);
> > > >> >            }
> > > >> >            else
> > > >> >            {
> > > >> >                base.DeleteEntity(session, entity, entityEntry,
> > > >> > isCascadeDeleteEnabled, persister, transientEntities);
> > > >> >            }
> > > >> >        }
>
> > > >> > The code above simply deletes the row, without propagating the
> > update
> > > >> > first.  I've also tried doing a session.Update(...) before the
> > > >> > CascadeBeforeDelete to no avail.
>
> > > >> > I wonder if you could offer any suggestions!  I'm quite new to
> > > >> > NHibernate, but appreciate its power and convenience :-)
>
> > > >> > Kindest regards,
>
> > > >> > Mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to