-->
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: "Where" clause support during update
PostPosted: Fri Mar 26, 2004 5:55 am 
Newbie

Joined: Fri Mar 26, 2004 5:01 am
Posts: 2
There are certain situations where we need to use "Where" clause while update. Mainly on concurrency handling situation.
In hibernate usual procedure is :
sess.load (object);
-- Update all the values in the object
then call object.save() or object.update()
then call sess.flush()

--> By the above scenario objects are saved to the database and flush will make sure that objects is flushed with current updated value in the memory.

This can take care of the concurrency inside the appplication (I.e if all the update happen through the hibernate within same application). But our situation is bit different, it is possible that database might be updated externally.
The updated values can not be reflected to the hibernate objects. So if some one does the update externally, and application may not aware of that, then it will also update the value in the database.
To avoid that we have a flag in database which will be automatically updated, whenever update happens by any means.
During the update call from application --> "Where" clause will be used to make sure the flag is same as while read.

Expected solution:
Hibernate says somethign about load --> Which locks the particular row in the database (SaveorUpdate()...).
I couldn't undestand this properly. If you can get the answer from the concerned person on how to handle:
Either
1. "Where" Clause while update
or
2. Lock the record before update (Which fetches the current value in the database as well).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 2:52 pm 
Newbie

Joined: Mon May 10, 2004 5:40 pm
Posts: 3
I'm a new user myself but if I understood your question properly then it seems that option 1 in your message can be accomplished with JDBC only. Messages posted on this form repeatedly say that you cannot add a where clause to an update via hibernate. Option 2 can be accomplished with LockMode.UPGRADE which produces a select.. for update statement.


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.