NHibernate IPreUpdateEventListener weird behaviour
Posted
by mcaaltuntas
on Stack Overflow
See other posts from Stack Overflow
or by mcaaltuntas
Published on 2010-04-29T21:33:23Z
Indexed on
2010/04/30
8:47 UTC
Read the original article
Hit count: 490
nhibernate
I am using NHibernate 2.0.1 and IPreUpdateEventListener,IPreInsertEventListener events for audit logging purposes.
I have a basic entity that has a one to many relation like this.
User------->Books
From an ASP.NET MVC controller method i am adding a book to a user like this.
Book book =new Book("LOTR");
var userBook=user.AddBook(book);
After session flushing OnPreInsert event called once for newly created Book object than OnPreUpdate called for all books objects in user's books collection even they have not changed.So I am updating LastMofiedDate property of all books objects and I dont want to do this. Is this supposed behaviour of NHibernate or am I missing something?
© Stack Overflow or respective owner