Reputation: 92
If I locked a row inside a method, and then called that method from another method inside the same class, would it retain the lock?
Locked row method has (as a prepared statement):
SELECT * FROM table_name WHERE row_name IN (?) FOR UPDATE
This method would take those selected and make a list (or array). Then a method in the same class would call the locked row method in order to get the list/array and do the actual updates.
Also note that I do want to have these in two different methods in the same thread (it is concurrent).
So, does it keep the lock for the updating method?
Upvotes: 0
Views: 77
Reputation: 53694
Database locks are not associated with Java classes or any other Java construct. They are associated with a Database transaction. Any work done within the transaction will be done with the lock. Any work done in a different transaction will be blocked by the lock.
Upvotes: 4