-->
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: Cascade in the opposite direction??
PostPosted: Thu Oct 19, 2006 5:02 am 
Newbie

Joined: Fri Mar 03, 2006 6:03 am
Posts: 8
Hi,

I need some guidance as to how this should be done. For example I have a unidirectional many-to-one association from Class A to Class B.
Every A instance has a B instance, and a B instance may be referred by many A instances...However Class B does not know about Class A. Hence unidirectional...

What I want to do is this: whenever a row in the database corresponding to a B instance is removed, I need the A instance rows in the database which refer to the deleted B instance are removed as well.

This is sort of a parent/child relationship where the parent does not know the children, and the children should be removed when the parent is removed...

Can this be done via Hbn cascading, or should be done programatically? Maybe I am confused too much, I don't know.

Hibernate version: 3.1


Top
 Profile  
 
 Post subject: Re: Cascade in the opposite direction??
PostPosted: Fri Oct 20, 2006 11:56 am 
Newbie

Joined: Wed Aug 03, 2005 6:49 pm
Posts: 9
I think there is only a programmatic way of this with something like

Code:
delete from A a where
a.b = :b


Many-to-one does not support all delete orphan as a cascade style.

bora.erbas wrote:
Hi,

I need some guidance as to how this should be done. For example I have a unidirectional many-to-one association from Class A to Class B.
Every A instance has a B instance, and a B instance may be referred by many A instances...However Class B does not know about Class A. Hence unidirectional...

What I want to do is this: whenever a row in the database corresponding to a B instance is removed, I need the A instance rows in the database which refer to the deleted B instance are removed as well.

This is sort of a parent/child relationship where the parent does not know the children, and the children should be removed when the parent is removed...

Can this be done via Hbn cascading, or should be done programatically? Maybe I am confused too much, I don't know.

Hibernate version: 3.1


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 26, 2007 4:08 am 
Newbie

Joined: Fri Mar 03, 2006 6:03 am
Posts: 8
Sorry for the late response, I have been away for a while and that project was cancelled :)
Thanks for the information...


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.