views:

219

answers:

1

I have an class for auditing:

public class AuditAfterAdvise : IAfterReturningAdvice

This is applied to a Dao class in my Spring.Net configuration, using a RegularExpressionMethodPointcutAdvisor.

The Dao class implementation calls HibernateTemplate.SaveOrUpdate(object entity) to commit changes.

I would like to be able to apply AuditAfterAdvise class to the HibernateTemplate SaveOrUpdate() method used in my Dao, rather than the methods on the Dao itself.

The NHibenate/Spring setup is to use a LocalSessionFactoryObject for the Dao. Is this possible?

Thanks.

A: 

It certainly should be possible.

Instead of configuring the Dao, add the advice to the object definition for the LocalSessionFactoryObject. The RegularExpressionPointCutAdvisor should continue to work -- just applied to a different object.

I'm assuming the HibernateTemplate is retrieved from a Spring.NET object factory...

Nader Shirazie