-->
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: ON DELETE SET NULL
PostPosted: Sat Dec 11, 2004 8:47 am 
Newbie

Joined: Sat Dec 11, 2004 7:49 am
Posts: 1
Location: Madrid, Spain
Hibernate version:Hibernate 2.1.2

Name and version of the database you are using:
MySql

I cannot find any feature related to the very useful "ON DELETE SET NULL" feature while I'm aware of the wonderful cascade="delete-orphan" feature, that can be mapped to the database as an "ON DELETE CASCADE" sentence.

Suppose I have a class/table named PARENT, while class/table CHILD contains objects that are related in an typical MANY-TO-ONE relationship.
Strong relations assert that when the parent is removed, all of his children must be removed also.

But many times this is not the case, and we have a "weak" relationship: when the PARENT is removed, the CHILDREN will silently loose the relationship to that object, because the children can in fact be orphan and their FK can be null. The problem is that if the application fails to set the FK to null, inevitably an exception will sooner or later happen when trying to retrieve the parent of the child.

ON DELETE SET NULL is the clause commonly used in the databases for this purpose. It magically releases the application from the task of reviewing the orphan rows to remove the link, by automatically setting the FK to NULL when the parent is removed.

Maybe this feature is anyhow considered inside Hibernate, but I coudn't find. Please anybody can help?


Top
 Profile  
 
 Post subject: Re: ON DELETE SET NULL
PostPosted: Sat Dec 11, 2004 9:55 am 
Newbie

Joined: Sun Oct 12, 2003 4:21 pm
Posts: 16
Location: Stockholm, Sweden
Me too!
I also need this feature and have not found a solution yet.

Hibernate version: Hibernate 2.1.7

Name and version of the database you are using: MsSql 2000


Top
 Profile  
 
 Post subject: Re: ON DELETE SET NULL
PostPosted: Thu Feb 24, 2005 7:51 pm 
Beginner
Beginner

Joined: Thu May 06, 2004 4:06 pm
Posts: 25
Any solution?

Is this do-able in Hibernate 2.1.x? Hibernate 3.x?


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.