Oracle UPDATE statements lock race condition 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!
As you can see from the documentation you supplied, oracle places an exclusive lock on the row during an update. This means that the second transaction in thread 2 will wait until thread 1 has committed and thereby releasing the lock on the row. If you only execute the UPDATE statement oracle will handle it for you.