Hi,
Trying to work out exactly how the locking works with Hibernate & SQL Server.
I need a transaction isolation of REPEATABLE_READ - and effectively, I am trying to do a SELECT "FOR UPDATE".
Now, using raw JDBC (with my JDBC Driver, JSQL Connect) if I execute a PreparedStatement with ResultSet.CONCUR_UPDATABLE, and autoCommit=false then my SELECT statements are serialized on the table (which is what I want). This isnt driver specific, is it?
I am trying to achieve the same with Hibernate - but my SELECT's arent being serialized. In fact, on committing the Hibernate Transaction, one thread gets a transaction deadlock exception from JSQLConnect:
com.jnetdirect.jsql.m: Transaction (Process ID 52) was deadlocked on {lock} resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
at com.jnetdirect.jsql.af.a(Unknown Source)
... more
I have verified the Isolation Level is correct (on the underlying connection).
I have tried creating a Query and setting the LockMode to WRITE (and have verified the LockMode on the objects themselves) however, I am still not getting the serialization I am expecting.
What am I missing?
Thanks.
Cheers.
Nick
|