-->
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: Conditional update based on timestamp
PostPosted: Tue Oct 07, 2008 5:57 pm 
Newbie

Joined: Tue Oct 07, 2008 5:36 pm
Posts: 1
I have an object graph, sent from a remote client, that I need to write into a database, but only if the value of the "lastUpdate" attribute is greater than the current "last_update" column value in the database.

ie.
update doc_tbl set name=?, last_update = ?
where id=? and last_update <= ?

If last_update fails the compare, it is also an indicator to us that none of the embedded entities should be updated, either, so I don't want any updates to be attempted on related tables.

I looked into using a timestamp version, such as this:
<version column="last_update" name="lastUpdate" type="timestamp"/>
but sql gets generated like this:

update doc_tbl set name=?, last_update=?
where id= and last_update=?

so I'm not sure if that is the right idea to pursue.

Can someone point me in a direction to get started?

Thanks,
K


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.