-->
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.  [ 3 posts ] 
Author Message
 Post subject: Query.setLockMode() doesn't seem to actually set lockMode
PostPosted: Thu Aug 12, 2004 1:02 am 
Newbie

Joined: Tue Jul 27, 2004 11:28 am
Posts: 3
Under Hibernate 2.1.5 and 2.1.6 against Oracle 9.2.0 (via Oracle9Dialect), it seems that executing an HQL query with a lock mode set on a column alias via setLockMode("alias", LockMode.UPGRADE) doesn't actually mark the object as UPGRADEd in the session, at least in conjunction with joins. It does remember to put "for update" on the SQL though.

So something like this:

Code:
String MY_HQL
    = "          select foo "
    + "            from com.dmlloyd.Foo foo "
    + "inner join fetch foo.bar bar "
    + "           where foo.id = ? ";

Query q = session.createQuery(MY_HQL);
q.setLockMode("bar", LockMode.UPGRADE);
q.setLong(0, 1234);
Foo foo = q.uniqueResult();
LockMode currentMode = session.getCurrentLockMode(foo.getBar());
if (currentMode.lessThan(LockMode.UPGRADE)) {
    throw new RuntimeExcpetion("Barf: " + currentMode);
}


would end up showing: "Barf: READ" even though the object is locked in the database (and then some... I couldn't get Hibernate to do FOR UPDATE OF; even modifying Oracle9Dialect to return true for supportsForUpdateOf() didn't do it, so it just used a blanket FOR UPDATE across the join).

Any ideas?

_________________
- D


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 1:37 am 
Newbie

Joined: Tue Jul 27, 2004 11:28 am
Posts: 3
Ah, corrections.

1) Hibernate will indeed do FOR UPDATE OF ..., for some reason my modified Hibernate didn't deploy.

2) For Oracle 9i, the syntax of FOR UPDATE OF is "FOR UPDATE OF TABLE.*", not "FOR UPDATE OF TABLE", which I assume is why Oracle9Dialect currently returns false for that capability; though this seems like a trivial fix to me. Thus I have reverted to stock 2.1.6 again.

The main point of the message remains, however.

_________________
- D


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 12, 2004 3:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
um

i don't quite understand what you are saying in the first post ... but this area could be buggy in 2.1 (its better in 3.0), so submit a bug report to JIRA (please be a bit more specific though).

TIA


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.