-->
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: LockMode.UPGRADE_NOWAIT and setMaxResults
PostPosted: Wed Aug 10, 2005 11:36 am 
Newbie

Joined: Wed Aug 10, 2005 11:14 am
Posts: 4
Hi,

I'm attempting to reproduce a "select ... for update nowait where rownum < 2" in Hibernate version 2 against Oracle, but I'm running into difficulties.

Here's how I create the query:

Criteria criteria = session.createCriteria(Thing.class);
criteria.add(Expression.eq("aProperty", "someValue"));
criteria.setLockMode(LockMode.UPGRADE_NOWAIT);
criteria.setMaxResults(1);

When I execute this query however, I get an Oracle error:

ORA-00907: missing right parenthesis

and indeed when I look at the generated SQL I see this form:

select * from ( select this.A_PROPERTY as A etc... from THINGS this where this.A_PROPERTY='someValue' for update nowait ) where rownum <= 1

which indeed fails.

If I comment out the setMaxResults(1) bit it produces correct SQL, so it seems that LockMode.UPGRADE_NOWAIT and maxResults are not compatible.

Is this the case, or have I missed something?

Cheers

Nick Cotter


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 5:59 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
How do you do that in plain Oracle SQL?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 6:34 am 
Newbie

Joined: Wed Aug 10, 2005 11:14 am
Posts: 4
emmanuel wrote:
How do you do that in plain Oracle SQL?


I would do something along the lines of

select * from table where rownum < 2 for update nowait;


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 1:47 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I quote Gavin from the dev list.
Quote:
The problem was "sorta" fixed in HB3, but not really.

I'm not sure I will really be able to fix it completely.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 11, 2005 3:47 pm 
Newbie

Joined: Wed Aug 10, 2005 11:14 am
Posts: 4
emmanuel wrote:
I quote Gavin from the dev list.
Quote:
The problem was "sorta" fixed in HB3, but not really.

I'm not sure I will really be able to fix it completely.



Fair enough - I will try to get around it with a n SQL query directly.

Thanks

Nick


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.