-->
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: Removing linked objects by CascadeType.REMOVE
PostPosted: Wed Feb 14, 2007 7:22 am 
Newbie

Joined: Wed Feb 14, 2007 5:59 am
Posts: 2
Hibernate version: 3.2.0.ga

If I define a relation
Code:
@ManyToOne(cascade=CascadeType.REMOVE)
when an instance of the POJO where is defined this relation is deleted, that produces a attempt to delete the target of the relation, which is the "parent" of the current POJO, that is a nonsense.
In this case, like that the "on delete cascade" of Oracle, the expected behaviour would rather be that deleting the target of the relation produces the destruction of all the instances of entities which have a foreign key of this target.
If I want to have this behaviour, I must define as much relations
Code:
@OneToMany(cascade=CascadeType.REMOVE)
in a POJO as this POJO has foireign keys
That can be very heavy, and a lot less flexible that to define this rule on each foreign key (as Oracle does).

I had posted this message on JRA forum, but the answer was "it's a user hibernate question"...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 15, 2007 8:10 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Feel free to implement that and come back crying because your performances suck :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 16, 2007 3:47 am 
Newbie

Joined: Wed Feb 14, 2007 5:59 am
Posts: 2
emmanuel wrote:
Feel free to implement that and come back crying because your performances suck :-)


Which difference between :
- defining an annotation in an object on a foreign key, which would indicate that the object must be deleted il the object referenced by the f.k. is deleted
- defining a relation OneToMany in the object referenced by the f.k., and indicate on this "CascadeType.REMOVE" ?

The work in the database is the same, no ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 20, 2007 1:54 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Try it.

_________________
Emmanuel


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.