Java Mailing List Archive

http://www.gg3721.com/

Home » the NHibernate development list »

[NHibernate-development] NHibernate & Coarsed-Grained Locking

Steve Degosserie

2008-03-21

Replies: Find Java Web Hosting

Author LoginPost Reply
Following DDD, I've tried to apply coarsed-grained locking with NHibernate on Aggregate Roots. No matter if I use complex pattern to enforce Aggregate consistency in memory or not, what I want is that if a child entity of an Aggregate is modified and is requested to be saved by mistake (should save at the aggregate root level), NHibernate will cascade the change back to the Aggregate Root, whose version number will always be updated. This way, I think that we would have 'cheap' coarsed-grained locking.

Unfortunately, when I declare "cascade='save-update'" on my "many-to-one" relations from child entity to parent entity (up to the Aggregate Root), NHibernate doesn't take it into account ... when I try to save a modified child entity directly, NHibernate will update the child table only, but not the table corresponding to the Aggregate Root.

Problem is : NHibernate sees that my Aggregate Root is non modified and as such, doesn't issue any update statement. I've tried hacking up the IInterceptor but I didn't get any success there.

Any ideas ?

Thanks in advance,
Steve Degosserie

PS : I'm using the trunk version of NH.



Attachment: NHAggregateLock.rar (zipped)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Nhibernate-development mailing list
Nhibernate-development@(protected)
https://lists.sourceforge.net/lists/listinfo/nhibernate-development
©2008 gg3721.com - Jax Systems, LLC, U.S.A.