1
 update account set lastusedval=lastusedval+1 where isactive=1 returning 
 lastusedval;

How to execute above query in java? when i tried to execute in oracle its working but in java hibernate/jpa no way to store return value in update query.

By executing above query intention is to apply lock on db level when more than 1 request comes

2

1 Answer 1

0

Using jdbc prepared statement with registeroutparameter might help you to resolve this issue.

Creating an UPDATE RETURNING query in Hibernate

Sign up to request clarification or add additional context in comments.

1 Comment

Um, registerOutParameter (note spelling) is used with CallableStatement, not PreparedStatement. Good catch on the dup, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.