Does ayone know if pessimistic locking works in Hibernate version 3.2.4 sp1.
I do not see it working for gets for SQL Server 2005. I'm using org.hibernate.dialect.SQLServerDialect in my configuration.
Here is a couple examples of things that I tried to get it working.
Example 1:
bean = ((Session)em.getDelegate()).get(pojo.getClass(),key,LockMode.UPGRADE);
Session is org.hibernate.Session
em is javax.persistence.EntityManager
Example 2:
SQLServerDialect.getDialect().appendLockHint(LockMode.UPGRADE, pojo.getClass().getName());
What I'm trying to have happen is the hint applied to the sql statement
ie. FOR UPDATE
or
WITH (UPDLOCK,ROWLOCK)
I need the row locked while the transaction is opened (T1), which means it cannot be read by another transaction (T2) until the current transaction is commited (T1).
I saw some posts that as of version 3.2.2 this had not been working.
Any help would be greatlty appreciated.
Thanks,
Tim
|