-->
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.  [ 3 posts ] 
Author Message
 Post subject: using of cascade in hbm file?
PostPosted: Sun Jul 19, 2009 2:10 am 
Beginner
Beginner

Joined: Wed May 06, 2009 12:23 pm
Posts: 23
Hi ,


This allows children to be deleted when the parent is deleted.
so do I need to set the attribute value cascade is true on to the Parent Pojo or is it on to the Chile POJO ?

Thanks in advance.


Top
 Profile  
 
 Post subject: Re: using of cascade in hbm file?
PostPosted: Sun Jul 19, 2009 9:07 am 
Senior
Senior

Joined: Wed Sep 19, 2007 9:31 pm
Posts: 191
Location: Khuntien (Indonesia)
kiran7881 wrote:
Hi ,


This allows children to be deleted when the parent is deleted.
so do I need to set the attribute value cascade is true on to the Parent Pojo or is it on to the Chile POJO ?

Thanks in advance.


You need to put the cascade in the parent class.


Top
 Profile  
 
 Post subject: Re: using of cascade in hbm file?
PostPosted: Mon Jul 20, 2009 1:57 am 
Newbie

Joined: Fri May 29, 2009 2:21 am
Posts: 12
Hi,

I would say, it depends on the relationship existing between Parent and Child objects.
To elaborate more, consider below examples:

Scenario 1:

Parent has 1-to-many with Child
Child has many-to-1 with Parent

We can, as specified in earlier post, use cascade on Parent hbm to save/delete Child.

Scenario 2:

Only Child has many-to-1 with Parent: On DB side, Child table would have Parent_ID as F.K.
In this case, Child hbm would have cascade which will
On insertion: Insert in Parent and then in Child tables.
On Deletion: Delete from Child and then from Parent tables.

Regards
Nitesh


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.