-->
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: Deleting child in a one-to-many unidirectional mapping
PostPosted: Tue Apr 18, 2006 6:38 am 
Newbie

Joined: Wed Mar 29, 2006 11:19 pm
Posts: 4
Hi,

I am using a one-to-many unidirectional mapping.
I am trying to delete the child records, but all Hibernate does is to set the foreign key to null, resulting in orphan records.

Using cascade="all-delete-orphan" did not work.

Is there any workaround this? I am unable to change it to bidirectional due to some contraints.

Thank you in advance.


Regards,
Vail


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 7:34 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
are you explicitly deleting the child records with session.delete(...) ?

_________________
Please don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 8:11 am 
Newbie

Joined: Wed Mar 29, 2006 11:19 pm
Posts: 4
No, I am removing the child object from the parent object, then saveOrUpdate the parent.

Is explicitly deleting the child the only way?



Vail


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 9:54 am 
Expert
Expert

Joined: Tue Dec 07, 2004 6:57 am
Posts: 285
Location: Nürnberg, Germany
I think so, because deleting it from the parent only removes the reference (sets the fk to null), not the child itself. You have to do this with session.delete

cascading only helps if you delete the parent with session.delete, this would also delete the children.

_________________
Please don't forget to rate


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.