-->
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: Delete object and flag record instead of removing from db
PostPosted: Fri Apr 22, 2005 4:51 am 
Newbie

Joined: Tue Dec 21, 2004 11:50 am
Posts: 3
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0.1

Name and version of the database you are using:
Oracle 9i

I want to keep a trace of deleted records in my db :

Tables
Code:
A(id, removed_flag)
B(id, a_id, removed_flag)


Records
Code:
A(1, false)
A(2, false)
B(1, 1, false)
B(1, 2, false)


After deleting A(1)
Code:
A(1, true)
A(2, false)
B(1, 1, true)
B(1, 2, false)


I saw that you can specify a where clause for fetching records from the db. Could 'where removed_flag=false' be used in combination with an interceptor that does not delete records but sets the flag instead ?

Or is there any other standard approach for modelling this kind of behaviour ? I guess you could also use some kind of database trigger, but I'm not too familiar with triggers...

Many thanks for all your comments,

Kristof


Top
 Profile  
 
 Post subject: use update instead
PostPosted: Fri Apr 22, 2005 6:00 am 
Beginner
Beginner

Joined: Thu Apr 21, 2005 5:37 am
Posts: 45
Location: Switzerland
Instead uf using the delete-function just modify the objects as you wish and save them. When you load your objects, look that you only load the ones, that have deleted=false.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 6:38 am 
Newbie

Joined: Tue Dec 21, 2004 11:50 am
Posts: 3
Marking each object explicitely would work, but what do you do when you have a complex object graph ?

I would love to rely on the cascade specification on my methods to properly delete and not bother to calculate this myself.


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.