All work

Select view

Select search mode

 
37 of 37

Bubble LifecycleVeto up from dependent collections

Won't Fix

Description

(Carried over from forum post http://forum.hibernate.org/viewtopic.php?p=2345556#2345556. Also I don't know whether this is better posted to the Hibernate side)

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.

Environment

None

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created May 29, 2007 at 1:44 PM
Updated June 30, 2008 at 6:59 AM
Resolved May 29, 2007 at 10:33 PM

Activity

Former user 
May 29, 2007 at 10:33 PM

There won't be any enhancements to ILifecycle in the future. Use an interceptor or create a method to check for this condition manually before actually deleting the entity.

Who's Looking?

Flag notifications