-->
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: logical cascade delete
PostPosted: Fri Sep 12, 2008 11:25 pm 
Newbie

Joined: Fri Sep 12, 2008 11:22 pm
Posts: 4
Hi,

Did anyone get logical delete with cascade to work
using hibernate. Instead of physically deleting the
records when a delete is made, a column in the record
should be set to false. The database schema has
parent-child relationships. So if a parent is deleted,
not only the record of the parent should be set to
false, even the column of the child record should be
set to false.

I am using Hibernate 3.

Any help would be appreciated.

Thanks,


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 14, 2008 7:41 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
That logic should probably be implemented by you, not by hibernate. For example, on the setEnabled() method of your parent class, it should traverse all the children and set them to the same value.
Another strategy would be to use a database trigger, and map your property as non-updateable in Hibernate.

_________________
Gonzalo Díaz


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.