Say I have a table MY_TABLE
without optimistic lock column. I have the following update statement that will be executed with org.hibernate.SQLQuery
:
UPDATE MY_TABLE SET NAME = ? WHERE SOME_NUMBER = ? AND NAME = ?
In some place in my Java code, I'll create a new async thread to execute this update. Say that at a given time after some seconds this thread is executed:
Thread 1:
UPDATE MY_TABLE SET NAME = 'TEST2' WHERE SOME_NUMBER = 3 AND NAME = 'TEST'
This operation can take some minutes. Few milliseconds later the following thread is executed:
Thread 2:
UPDATE MY_TABLE SET NAME = 'TEST3' WHERE SOME_NUMBER = 3 AND NAME = 'TEST'
I need to make sure that, since the rows affected are the same, the UPDATE
from the first thread is executed before the one from the second thread.
Does the default lock strategies from Oracle already guarantee that? Or do I need anything else?
Thanks!