I have a simple dao accessor in a transaction:
Code:
Task taskOrig = taskDao.getTask(multiId);
List results = getSessionFactory().getCurrentSession()
.createQuery("from Task t where t.multiId=:multiId")
.setParameter("multiId", multiId)
// for those databases that support it (mysql does)
.setLockMode("t", LockMode.UPGRADE)
.list();
if (results.size() == 0)
return null;
Task task = (Task) results.get(0);
0) Set a breakpoint at the top of the List ... code
1) mysql - begin;
2) mysql - select * from tasks for update;
3) step through hibernate code above
4) hibernate produces console select for update statement and waits
5) mysql - update the object
6) mysql - commit;
7) hibernate comes back but has not updated the object, only waited for the lock to be removed.
NOTE: Repeating WITHOUT the first taskOrig code and the select does get the right object (since there is nothing in the session).
I have tried various options, including .lock methods etc.
Anyone else had this problem?? I have resorted to using jdbc. Because I can mimic the correct behaviour in raw mysql and jdbc code replacing that above works, I am sure this should be a JIRA?
hibernate 3.2.0ga
mysql 5.0.22 (innoDB)