-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: setLockMode() does not work in Hibernate 3.5.6
PostPosted: Wed Nov 10, 2010 4:48 am 
Newbie

Joined: Fri Jun 17, 2005 2:07 am
Posts: 19
Location: Berne, Switzerland
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.