-->
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 delete revisited
PostPosted: Tue Nov 28, 2006 2:53 pm 
Newbie

Joined: Tue Nov 28, 2006 2:37 pm
Posts: 7
I'm trying to implement a logical delete for one of my objects managed by Hibernate. For a deletion of my object type "Item", I want to set isActive=false and modifiedDate=currentDate, and not delete the record from the db. I also want any associated objects to be deleted (true delete, not logical) as setup by the cascade parameters on the associations. There is also a set of associated child "Item" objects, which should be processed by the same logical delete algorithm I just described. Essentially a delete of an "Item" can result in a deletion of a tree of Items.

From reading other posts on this topic I found I could specify custom sql with sql-delete. This works great. The entire tree is deleted exactly as described above, but the only problem is that it is nearly impossible to write sql to do what I want that will work on multiple databases.

The only other solution I found was to implement a delete event listener of some type, but everything I read left me thinking that the cascading would be difficult to implement (especially when we are talking about deleting a tree of items). Can this be done? The advantage of this is that I wouldn't have to write db specific sql.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 29, 2006 7:17 am 
Senior
Senior

Joined: Mon Oct 23, 2006 5:12 am
Posts: 141
Location: Galicia, Spain
how about using

org.hibernate.Interceptor.onPrepareStatement(String sql)

and change the delete statement to an update statement?

_________________
andresgr (--don't forget to rate)


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.