I tried using lock hints with SQL Server 2000 and Hibernate 3.1.2. I tried setLockMode on HQL Query but hibernate fails to append lock hint in HQL queriy. I upgraded to version 3.2.6. The SQLServerDialect contains a method appendLockHint(LockMode mode, String tableAlias) but this code is not called up while converting HQL queries to SQL.
It seems that hibernate developers know about the problem and tried to fix it in the previous versions but they seem to have lost the patch. The link below points to a JIRA which describes it.
http://opensource.atlassian.com/project ... se/HB-1532
Also applyLocksToSql() of the dialect class (SybaseDialect) seem to apply lock hint only in case of upgrade. In case of read it doesn't seem to apply lock hint. But this only seems from the code which doen't actually runs.
What I thought is to use
query.setLockMode(LockMode.READ, tableAlias) or query.setLockMode(LockMode.UPGRADE, tableAlias) and see WITH (READPAST) or WITH (updlock, rowlock) appended to my query when it runs.
Or any other way to insert lock hint in HQL queries