-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Use of LifecycleVeto on dependent collections
PostPosted: Tue Mar 27, 2007 3:23 pm 
Newbie

Joined: Thu Dec 14, 2006 11:14 pm
Posts: 6
I am using ILifecycle under NHibernate 1.2.0 CR1 and hitting a limitation of the LifecycleVeto for OnDelete. I have an entity with a child collection that is configured for cascade="all-delete-orphan". If I delete the top most object, the whole object graph is deleted from the database which is great. If I have logic in ILifecycle.OnDelete for the top object and return a LifecycleVeto.Veto, then the whole deletion is canceled as I would hope. However, if it is one of the child objects that returns the Veto in its own ILifecycle.OnDelete, NHibernate still tries to persist the deletion of the parent (and other children). In my case, an exception subsequently results from the violation of a database foreign key constraint.

I would guess this is "functions as designed", but I figured I would see if anyone has any creative solutions to this other than just checking all child objects from the parent's OnDelete?

It seems like it would be a nice enhancement to ripple a child's Veto up the dependent collection chain. Although, I would imagine there would need to be some clear restrictions (e.g. a one to many relationship with cascade...) or have this be configurable in some way.

Another workaround would be to throw a CallbackException in the child's OnDelete, but that doesn't feel right for a "normal" execution flow. In my case, I am trying to not delete this object graph if some outside entity has a many-to-many association into one of the child objects.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.