I’m using Spring.NET AOP to determine when a C# persistent object has change any of its properties (per Spring.AopQuickStart.Step6.2010 in Spring.NET/examples), but I’m getting a MappingException – No persister for: DecoratorAopProxy_8aa4d47e877a48b4828bf7a6a51bbedf
Here’s my code:
var person = Repository.GetById(personId);
var personProxy = GetProxy(person);
// udpate some properties in personProxy - this is where my advisor determines if/what has changed
Repository.Save(personProxy); // exception thrown here
Here’s what GetProxy looks like (per the AopQuickStart example):
private static Person GetProxy(Person target)
{
var proxyFactory = new Spring.AOP.Framework.ProxyFactory(target);
proxyFactory.AddAdvisor(new ModificationAdvisor(target.GetType()));
proxyFactory.AddIntroduction(new IsModifiedAdvisor());
proxyFactory.ProxyTargetType = true;
return (Person)proxyFactory.GetProxy();
}
I think the issue is that the GetType for the object passed to NHibernate’s session Save is “DecoratorAopProxy”, and not Person which throws NHibernate off.
How can I solve this issue?
look at the implementation of DataBindingIntercepter.cs and DataBindingFactory.cs
https://github.com/ayende/Effectus/tree/master/Effectus/Infrastructure