-->
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: HQL update based on existing values.
PostPosted: Sun Dec 30, 2007 4:07 pm 
Newbie

Joined: Sun Dec 30, 2007 3:58 pm
Posts: 7
Hi,

How can I make hibernate perform a Query such as the following:

"Update [versioned] MyEntity set MyProperty = (MyProperty + 3) where ... "

I don't really want to do it in the Java code, since then I'll get into concurrency issues (dirty writes). I Simply want the DBMS to handle the transaction management for me.

Is it possible at all?

*[versioned] - I might want the change to reflect in the in-memory entities.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 31, 2007 8:17 am 
Newbie

Joined: Sun Dec 30, 2007 3:58 pm
Posts: 7
I managed to make it generate the SQL query

update MyEntity set prop = (prop - ?) where ..)

It bind the right values where it should but it does not execute the update
for some reason.


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.