-->
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: whats the Hibernate Equivalent for this SQL
PostPosted: Fri Jul 17, 2009 3:58 pm 
Beginner
Beginner

Joined: Thu May 28, 2009 10:25 am
Posts: 21
Here's a sample performance critical query in SQL that I'm wary of porting to Hibernate
Quote:
UPDATE METRICS SET DOCS=DOCS+100, PAGES=PAGES+100, SIZE=PAGES+100 WHERE GROUPID=1 AND GROUPTYPE='C' AND TYPE='viewed'


From what I understand , HQL can't be used on save / update methods.
Basically, my question boils down to the following:

1. Is there a way to have Hibernate increment the existing, say, PAGES value without the overhead of first retrieving the METRICS or PAGES value from the Hibernate back to the application ?
2. Is there a Hibernate specify way to perform the increment operation ?

I expect only one entry to match the WHERE criteria, but the operation is performed multiple times by (potentially) multiple users, so I'd rather not get into the whole scenario of retrieving the METRICS object , updating it (and dealing with , as I understand it, a @Version tag to avoid a potential lock)
Thanks


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.