-->
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.  [ 2 posts ] 
Author Message
 Post subject: LockMode.Upgrade never re-loads from db if in session -JIRA?
PostPosted: Tue Oct 17, 2006 1:38 pm 
Newbie

Joined: Thu Jul 06, 2006 8:04 am
Posts: 14
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)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 18, 2006 4:17 am 
Newbie

Joined: Thu Jul 06, 2006 8:04 am
Posts: 14
Hmm...

Am thinking that this could just be the design of Hibernate - in that, differences in the database are to be sought out using versioning. I should perhaps post my question on why the refresh() doesn't seem to get the latest - hopefully I'll work why that is some day.


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

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.