-->
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: Deleting object with one-to-many relationship
PostPosted: Wed Mar 28, 2007 8:20 am 
Newbie

Joined: Thu Dec 14, 2006 7:36 am
Posts: 6
Hello,

My question is rather abstract but I was wondering why developer should manually remove given object from the associated objects' single- or many-valued properties prior delete?

I would like to automate the deletion by crawling all the associated object's collection and remove the current object from there. Have you guys done something like this so you can share opinions/patterns?

Thank you in advance!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 9:55 am 
Newbie

Joined: Tue Sep 20, 2005 10:13 am
Posts: 5
Do you mean cascade delete?

I use hibernate annotation
@ManyToOne(cascade=CascadeType.REMOVE)
@OneToMany too


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 10:02 am 
Newbie

Joined: Thu Dec 14, 2006 7:36 am
Posts: 6
monzdrpower wrote:
Do you mean cascade delete?

I use hibernate annotation
@ManyToOne(cascade=CascadeType.REMOVE)
@OneToMany too


Not really, because CascadeType.REMOVE deletes the associated objects. I actually need to break the the relation to the associated objects and delete current object. I would like to avoid manually removing the object from associated object's collections.

Currently I get ConstarantViolationException if I don't break the relation prior delete.


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.