-->
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.  [ 5 posts ] 
Author Message
 Post subject: query.setLockMode()
PostPosted: Thu Sep 18, 2003 10:39 am 
Beginner
Beginner

Joined: Fri Sep 12, 2003 5:13 am
Posts: 22
Hello,

I'm using query.setLockMode("cumTra", LockMode.UPGRADE) with LockMode.UPGRADE, but the generated SQL doesn't have "FOR UPDATE" .

The query look like this :
Code:
    "from cumTra in class fr.testTra where ..."
The database is SAP DB.

(For information, i've tried to use session.refresh :
Code:
    session.refresh(cumTra, LockMode.UPGRADE);

and it was ok).

Any idea ?

Philippe


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2003 5:13 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Does your database support SELECT FOR UPDATE ?
Did you correctly set your DB Dialect ?

Quote:
Session.lock() performs a version number check if the specified lock mode is READ, UPGRADE or UPGRADE_NOWAIT. (In the case of UPGRADE or UPGRADE_NOWAIT, SELECT ... FOR UPDATE is used.)

If the database does not support the requested lock mode, Hibernate will use an appropriate alternate mode (instead of throwing an exception). This ensures that applications will be portable.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 19, 2003 2:20 am 
Beginner
Beginner

Joined: Fri Sep 12, 2003 5:13 am
Posts: 22
Yes it does (SAP DB Dialect support FOR UPDATE since Hibernate 2.0.2 ou 2.0.3), that's why I say that it was ok with a session.refresh(x, LockMode.UPGRADE) or a session.load(x, LockMode.UPGRADE).

Philippe


Top
 Profile  
 
 Post subject: Re: query.setLockMode()
PostPosted: Fri Sep 19, 2003 2:33 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
There seems to be a slight bug in the query parser which doesn't set
cumTra as an aliasName, but I'm not sure of it.

Try the
Code:
from fr.testTra as cumTra
structure.

Hibernate guys,
in n.s.h.hql.FromParser#token method in
Code:
else if (afterIn) {
...
  if (afterClass) {

I think you must add an
Code:
q.setAliasName(alias, ?);


as it is in the previous section
Code:
if ( afterAs || expectingAs ) {
            
  if (entityName!=null) {
    q.setAliasName(token, entityName);
}


Because locks by alias use the undelying QueryTranslator.aliasNames Map to match.

Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 21, 2003 10:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ahhh hmmmm urggghhh.....


this Query.setLockMode() method is a bit questionable at present, since it really only applies to postgres and perhaps one other database ... I need to figure out how to make it a bit more generic.


You are probably right about that bug, but note that the "foo in class Foo" syntax is heavily deprecated. If it works for "Foo as foo", I'm inclined to not fix this bug.


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