Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
SQL: select for update with uniqueResult #327
Select for update with AbstractSQLQuery.uniqueResult produces illegal SQL on Oracle:
-> ORA-00907: missing right parenthesis
Putting the "for update" at the end of the query should work
Anyhow, I'm not quite sure I like that uniqueResult (as well as singleResult) wrap the actual query with rownum-wrapper-select. It would probably be safer and at least more transparent if it would use the query as such and then process only the first row. Using those methods implies that user knows there is only one relevant match.
added a commit
Jan 18, 2013
Thanks for the fix!
I agree about the semantics of those methods, just not the implementation as it modifies the request in a way that may even break the query. It would be easy enough to achieve the same semantics without query modification:
It doesn't break anymore and is a valid optimization that is also utilized in JPA implementations. The forUpdate() case was broken for explicit and implied limit/offset cases, not only for uniqueResult and singleResult.