Event Listener not firing on hasManyToMany mapped property
I'm implementing automatic auditing on an app I'm working on and I'm
having a problem getting the PostUpdateEvent listener to fire when I
change a property which is mapped as a HasManyToMany.
Below is my map. If a change is made to any of the properties other
than "AdministersUnit" the PostUpdateEvent Listener is fired on the
update.
If I change more than one property and AdministersUnit the postupdate
still doesn't pickup that AdministersUnit has changed. I've just
tried it with a PreUpdate event listener and the same behaviour is
there.
If anyone have any suggestions or a workaround I would be very
grateful!
public class UserMap : ClassMap {
public UserMap()
{
Id(x => x.Id);
Map(x => x.UserName).Not.Nullable().Length(50);
Map(x => x.Name).Length(100);
Map(x => x.Email).Length(100);
References(x => x.Unit).Nullable();
Map(x => x.IsAdmin).Default("'false'");
Map(x => x.WarningMessagesOn).Default("'true'");
HasManyToMany(x => x.AdministersUnit).LazyLoad();
}
}
Cheers
Rob
Support Staff 2 Posted by Paul Batum on 19 Oct, 2010 07:05 AM
I haven't tried auditing a many-to-many relationship, but I can see how it
might be a little bit different to other auditing scenarios (because neither
the User, nor the Unit is changing - its the joining table that is
changing).
You might be best off asking for help on the nhibernate
users<http://groups.google.com/group/nhusers/> mailing
list as this is really a question that is specifically about NHibernate's
behavior. If they ask you for an xml version of your mappings, see here:
http://wiki.fluentnhibernate.org/Fluent_configuration#Exporting_mappings
On Tue, Oct 19, 2010 at 9:01 AM, Rob Booth <
***@tenderapp.com<tender%***@tenderapp.com>
> wrote:
3 Posted by Rob Booth on 19 Oct, 2010 07:27 AM
Hi Paul,
Thanks for the response, I'll post the query there too.
Yes, I can see that it's the 'table in the middle' of the many to many that's being updated and I was wondering if this was the problem.
Cheers
Rob