-->
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.  [ 4 posts ] 
Author Message
 Post subject: Concurrency in parent/child relationships
PostPosted: Fri Aug 19, 2005 10:45 am 
Newbie

Joined: Thu Apr 28, 2005 2:18 pm
Posts: 4
Suppose we have a parent/child relationsship and a bidirectional mapping properly set.
When I load a parent object I also get a list of all childs. Now I want to delete the parent and all it associated childs. But in the meantime another user has added an new child to the same parent. So this child is not in the child list of my parent object.
My question: When I delete the parent, will the new child of the other user also be deleted or will Hibernate delete only those childs which are in the parents child list? How to deal with such situations?

Thanks for your help
Bruno


Top
 Profile  
 
 Post subject: Re: Concurrency in parent/child relationships
PostPosted: Fri Aug 19, 2005 4:51 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Bue wrote:
Suppose we have a parent/child relationsship and a bidirectional mapping properly set.
When I load a parent object I also get a list of all childs. Now I want to delete the parent and all it associated childs. But in the meantime another user has added an new child to the same parent. So this child is not in the child list of my parent object.
My question: When I delete the parent, will the new child of the other user also be deleted or will Hibernate delete only those childs which are in the parents child list? How to deal with such situations?

Thanks for your help
Bruno


Bruno,

If you're using cascade="delete-orphan" on the child-set, I'm 99% sure that the delete query that gets created is something like "delete from child where parentId = ?" so it would also delete the new child.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject: Re: Concurrency in parent/child relationships
PostPosted: Sat Aug 20, 2005 4:56 am 
Newbie

Joined: Thu Apr 28, 2005 2:18 pm
Posts: 4
pksiv wrote:
Bue wrote:
Suppose we have a parent/child relationsship and a bidirectional mapping properly set.
When I load a parent object I also get a list of all childs. Now I want to delete the parent and all it associated childs. But in the meantime another user has added an new child to the same parent. So this child is not in the child list of my parent object.
My question: When I delete the parent, will the new child of the other user also be deleted or will Hibernate delete only those childs which are in the parents child list? How to deal with such situations?

Thanks for your help
Bruno


Bruno,

If you're using cascade="delete-orphan" on the child-set, I'm 99% sure that the delete query that gets created is something like "delete from child where parentId = ?" so it would also delete the new child.


Thanks for your help!
I tried it out with cascade="delete-orphan". The problem now is that the parentId of the orphaned child is set to integer 0 but the child itself is not deleted. Is there another option to set?


Top
 Profile  
 
 Post subject: Re: Concurrency in parent/child relationships
PostPosted: Sat Aug 20, 2005 10:52 am 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
Can you post your mapping files ?

Also, look at the inverse="true" attribute in the docs.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.