-->
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.  [ 1 post ] 
Author Message
 Post subject: Replace Delete with a Update
PostPosted: Thu Jan 20, 2011 5:48 am 
Newbie

Joined: Thu Jan 20, 2011 5:25 am
Posts: 1
I have here a very big and complex legacy datamodell on which i mapped entities with hbm 3.5.

Problem
The speciell on this datamodel you shouldn't delete entries in the database you just update a validToDate value.
Code:
@Entity
class Address{
      int id;
      List children;
      Date validTo;
}

Code:
session.delete(address) - should do > UPDATE address SET validTo=current_date() WHERE id =1

every table has this column. Advantage: the change of values is transparent.


Possible solutions I thought:
- with a DAO you can write DAO.delete(address) and make internally a update.
The Problem are the children, which should be deleted over @Cascade(value = CascadeType.DELETE_ORPHAN).
I could relinquish this, but than I need a easy transparent solution (the datamodel is very big and complex - i generated it over hbm generator)
- Hibernate Interceptors could catch the delete, but can not change it into update
- On DB level (Postgres) I could use on delete trigger, but sometimes I need a real delete


Also the retrieve of the data with WHERE validToDate>=currentDate() i want to solve transparent

Perhaps somebody knows this problem or has a idea. thx


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.