-->
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: mark entity as deleted but not delete it
PostPosted: Tue Oct 12, 2010 9:11 am 
Newbie

Joined: Mon Oct 11, 2010 11:49 am
Posts: 2
Hello, good day. Could you please help me.
I have a table. And 3 fields in it.
id,
name,
surname

name and surname are Composite key.
Application can add, delete, update records in this table.
I added 2 fields in this table - timeCreated, timeDeleted. And when I'll to delete, I need just set timeDeleted for this record, but not to delete it !
But I have a problem - ConstraintViolationException. Because when I set timeDeleted I can not to set the same record in this table.
For example:
I added a new record
Quote:

id | name | surname | timeCreated | timeDeleted

1 | Andy | Somethi | 10.10.2010 | null

then I'll delete it. Result:
Quote:

id | name | surname | timeCreated | timeDeleted

1 | Andy | Somethi | 10.10.2010 10:10 | 10.10.2010 10:15

Then, I want to add the same name and surname. But I can not, because composite key by name and surname will throw to me ConstraintViolationException.

How can I resolve this problem ?


Top
 Profile  
 
 Post subject: Re: mark entity as deleted but not delete it
PostPosted: Tue Oct 12, 2010 9:34 am 
Newbie

Joined: Wed Aug 25, 2010 4:35 am
Posts: 8
Hi,
as I understood you are trying to inserting a new record for the same name and surname,
thats why its giving error.
you can update record (null value with deletion time)


Top
 Profile  
 
 Post subject: Re: mark entity as deleted but not delete it
PostPosted: Tue Oct 12, 2010 9:44 am 
Newbie

Joined: Mon Oct 11, 2010 11:49 am
Posts: 2
asitjaiswal, thank you for answer.
I know reason of error. But I need to insert new record with the same name and surname. And first field should me mark as deleted.
How can I come over composite key for records, which mark as deleted ?


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.