-->
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: Specifying delete order for child one-to-many associations
PostPosted: Mon Jun 13, 2005 3:20 pm 
Newbie

Joined: Sat Sep 06, 2003 9:29 pm
Posts: 6
Location: Minneapolis, MN
We have an existing data model that we're try to model using Hibernate 3. Our object model contains Sponsor objects, each of which has a one-to-many relationship to PlanYear objects and a one-to-many relationship to Policy objects. Sponsor controls the lifecycle of both of these relationships using a cascade style of "all". Policy also contains a many-to-one relationship with a PlanYear (also linked to the Sponsor), but it does not control the lifecycle of the PlanYear (hence the cascade style is "none"). Policy must contain a PlanYear, thus the many-to-one relationship not-null is set to "true".

We have a test case where we have created a object graph of a single Sponsor object, PlanYear objects, and Policy objects and when we try to delete the Sponsor (and cascade the delete to Policy and PlayYear relationships), we have problems with the PlanYear objects are being deleted before the Policy objects are deleted, thus causing not-null constraint problems in Hibernate (or in the database if the not-null constraint is relaxed in the Hibernate mapping of Policy).

Is there any way to control the delete order within the Sponsor mapping to correctly remove the Policies before removing the PlanYears? Interesting, we're also evaluating TopLink and it has the same problem with our data model. The person doing the TopLink spike seems to think that TopLink has mapping logic to take care of this. We'll see.

Kind regards,

-- chris bartling --


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.