-->
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.  [ 2 posts ] 
Author Message
 Post subject: Cascade attribute setting for one-to-many relationship
PostPosted: Fri Apr 14, 2006 12:42 pm 
Newbie

Joined: Thu Aug 25, 2005 5:33 pm
Posts: 10
Hi,

I have a one-to-many relationship, say Order to Orderlines. Is it possible to define the cascade attribute for this relationship so that if the last Orderline object is deleted then the Order is also automatically deleted? Obviously, deleting any Orderline object except for the last one would not delete the Order.

Or is this something I can only do programmatically?


thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 14, 2006 1:07 pm 
Beginner
Beginner

Joined: Thu Aug 19, 2004 2:33 pm
Posts: 30
Location: CA, USA
I don't think so since the Orderline object is the child of the Order object. But see section 10.11. Transitive persistence in the Hibernate v3 documentation.

Quote:

...
Recommendations:

* It doesn't usually make sense to enable cascade on a <many-to-one> or <many-to-many> association. Cascade is often useful for <one-to-one> and <one-to-many> associations.
* If the child object's lifespan is bounded by the lifespan of the of the parent object make it a lifecycle object by specifying cascade="all,delete-orphan".
* Otherwise, you might not need cascade at all. But if you think that you will often be working with the parent and children together in the same transaction, and you want to save yourself some typing, consider using cascade="persist,merge,save-update".

...


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

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.