-->
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.  [ 2 posts ] 
Author Message
 Post subject: Can't get deleting on cascade to work
PostPosted: Tue Oct 19, 2010 5:47 am 
Beginner
Beginner

Joined: Thu Sep 17, 2009 8:53 am
Posts: 20
Hi there,
I'm stuck on the following problem:

I have two tables A and B. A has got a nullable foreign key to B.
If I delete a row from A, I want the corresponding row in B to be deleted as well.

Here is what I tried in my .hbm.xml files:

<class name="A" table="A" >
....
<many-to-one name="B" column="b" not-null="false" class="B" foreign-key="FK_a_to_b" cascade="all" lazy="false"/>
...
</class>

If I now delete a row from A, the associated row in B remains where it is.
I would have thought, the solution would be to use cascade="all-delete-orphan", but this does not seem to be defined for many-to-ones.

My question is:
What would be the preferred way to do what I intend here?

Thanks a lot in advance!


Top
 Profile  
 
 Post subject: Re: Can't get deleting on cascade to work
PostPosted: Wed Oct 20, 2010 7:41 am 
Senior
Senior

Joined: Fri Oct 08, 2010 8:44 am
Posts: 130
Your definition is correct. No need to user orphans here (there are mostly needed for collections). Could you give more details on how you perform your delete operation?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.