I have two questions regarding the Pessimistic LockModes that are available in Hibernate 3.3.2.ga :
If I lock a set of rows using lockmode UPGRADE, do the locks gets released when you move out of the transaction scope? If yes, can we lock-unlock across transactions?
For the following scenario, which LockMode would be useful
Thread 1, tries to obtain a lock and locks a set of rows
Thread 2, tries to obtain the lock on the same set of rows (as were locked by Thread 1) at this time thread 2 gets a exception saying that Rows are locked
Which would be the best pessimistic LockMode?