hi,
we moved from hibernate 3.3.2 to 3.5.6 and have a problem with LockMode not propagated into the SQL (Oracle 11).
see
http://opensource.atlassian.com/project ... e/HHH-5239 and
http://opensource.atlassian.com/project ... e/HHH-5275.
i have the following queries (hql and criteria):
Query query1 = session.createQuery("from BaDbs_Cat cat where cat.name like :name");
query1.setParameter("name", BuBv_TextX200Helper.createText("% testLockMode " + id));
query1.setLockMode("cat", LockMode.UPGRADE);
List result1 = query1.list();
Criteria crit = session.createCriteria(BaDbs_Cat.class);
crit.add(Restrictions.like("name", BuBv_TextX200Helper.createText("% testLockMode " + id)));
crit.setLockMode(LockMode.UPGRADE);
List critResult = crit.list();
with both queries the fragment "for update" is not added to the SQL-String and thus the row is not locked.
both queries used to work with hibernate 3.3.2.
i found a workaround using my own OracleDialect where i override the new method
getForUpdateString(String aliases, LockOptions lockOptions):
Code:
public class My_Oracle10Dialect extends Oracle10gDialect
{
public My_Oracle10Dialect()
{
super();
}
@Override
public String getForUpdateString(String aliases, LockOptions lockOptions)
{
// BRJ: 10.11.2010: Workaround für Problem mit setLockMode() in Hibernate 3.5.6
return getForUpdateString(aliases);
}
}
my queries both work with this workaround. i'm not sure if this is the way to go until hibernate fixes this issue.
for hql-queries locking works with setLockOptions() instead of setLockMode()
Code:
query1.setLockOptions(new LockOptions(LockMode.UPGRADE));
but setLockOptions() is not available in criteria-query.
jakob