Thanks will give it a look. Is there any reason why using default will not work?


Cheers
Stefan

On Tue, Jan 13, 2009 at 11:17 AM, Dario Quintana
<[email protected]> wrote:
> Hi
>
> Maybe you are looking for IPreInsertEventListener and
> IPreInsertEventListener.
>
> Best regards
>
> On Tue, Jan 13, 2009 at 12:11 AM, Stefan Sedich <[email protected]>
> wrote:
>>
>> Hi,
>>
>> I created a custom event listener like so:
>>
>>  public class AuditingEventListener : DefaultSaveEventListener {
>>
>>        protected override object PerformSave(object entity, object
>> id, global::NHibernate.Persister.Entity.IEntityPersister persister,
>> bool useIdentityColumn, object anything, IEventSource source, bool
>> requiresImmediateIdAccess) {
>>            var ent = entity as IAuditableEntity;
>>
>>            if (ent != null) {
>>                ent.LastModified = DateTime.Now;
>>                ent.CreatedDate = DateTime.Now;
>>            }
>>
>>            return base.PerformSave(entity, id, persister,
>> useIdentityColumn, anything, source, requiresImmediateIdAccess);
>>        }
>>
>>        protected override void PerformUpdate(SaveOrUpdateEvent
>> @event, object entity,
>> global::NHibernate.Persister.Entity.IEntityPersister persister) {
>>            var ent = @event.Entity as IAuditableEntity;
>>
>>            if (ent != null) {
>>                ent.LastModified = DateTime.Now;
>>            }
>>
>>            base.PerformUpdate(@event, entity, persister);
>>        }
>>
>>    }
>>
>>
>> And config like so:
>>
>> <listener class="App.AuditingEventListener, App" type="save" />
>> <listener class="App.AuditingEventListener, App" type="update" />
>>
>>
>>
>> Now the save is getting called on insert, but update is not getting
>> called, if I add
>>
>>  protected override object PerformSaveOrUpdate(SaveOrUpdateEvent @event) {
>>            var ent = @event.Entity as IAuditableEntity;
>>
>>            if (ent != null) {
>>                ent.LastModified = DateTime.Now;
>>
>>            }
>>
>>           return base.PerformSaveOrUpdate(@event);
>>        }
>>
>> this is getting called on save and updates, how can I get the update
>> only listener to be called? Am I missing something simple here.
>>
>>
>>
>>
>> Thanks
>>
>> --
>> Stefan Sedich
>> Software Developer
>> http://weblogs.asp.net/stefansedich
>>
>>
>>
>
>
>
> --
> Dario Quintana
> http://darioquintana.com.ar
>
> >
>



-- 
Stefan Sedich
Software Developer
http://weblogs.asp.net/stefansedich

--~--~---------~--~----~------------~-------~--~----~
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