-->
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: many-to-one and cascade delete
PostPosted: Thu Feb 14, 2008 11:26 am 
Newbie

Joined: Tue Oct 23, 2007 6:41 am
Posts: 6
Hi forum,

I need your help with many-to-one relation: I have many-to-one relation and I would like to force hibernate to create real database "on delete cascade" contraint. I know I can add cascade="delete" and hibernate will call extra delete command, but I would like yo have real database constraint because I thing it is more effective.
How can I achive it?

Thanks for your advice.

Smoke


Top
 Profile  
 
 Post subject: Re: many-to-one and cascade delete
PostPosted: Thu Feb 14, 2008 3:43 pm 
Senior
Senior

Joined: Fri Jun 01, 2007 12:41 pm
Posts: 121
Check this example from Hibernate Book, section 8.3.5 Database constraints.

Code:
<class name="Item" table="ITEM">
...
<set name="bids" cascade="save-update, delete">
<key column="ITEM_ID" on-delete="cascade"/>
<one-to-many class="Bid"/>
</set>
</class>


Now your database generate ON DELETE CASCADE constraint as on-delete="delete" is given to column ITEM_ID


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 15, 2008 2:17 am 
Newbie

Joined: Tue Oct 23, 2007 6:41 am
Posts: 6
Yes, I read it. But how can I do it from many-to-one side? We don't have corresponding "<set ...><one-to-many...." definition because the definition is needless for our bussiness logic.

Thanks

Smoke


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.