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