-->
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: Cancel a deletetion in the same transaction.
PostPosted: Thu Apr 14, 2005 9:39 am 
Newbie

Joined: Thu Apr 14, 2005 9:02 am
Posts: 7
There is an isolated database table named "MESSAGE", with correspond class Message.

In a transaction, there exists a persistent Message object named "message".

Now,
session.delete(message);
// Now message is a transient object, isn't it?

Later, in the same transaction:

// Cancel the previous delete, so that object message
// becomes the original persistent object before the deletion.

// And then
message.setText("...");

// Finally,
tx.commit();
session.close();

How to do that
without an application-layer "deletetion-buffer", and
Hibernate generates only one "update" SQL statement ?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 14, 2005 11:44 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
You may have considered this - but why not delay the deletion of the message until you know for sure that you are actually going to delete it?
i.e.
Code:
// some code

if (requireDelete) {
    session.delete(message);
}
else {
    session.update()
}


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.