-->
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: CreateQuery & setLockMode
PostPosted: Sat May 28, 2005 11:30 am 
Beginner
Beginner

Joined: Fri Sep 24, 2004 7:15 am
Posts: 40
Hi,

I'm implementing a DAO method to retrieve the next id in a column using pessimistic blocking, so I'm sure that anyone else uses the same number (what would derivate in a primary key violation).

My code is:

Integer maximo = null;
Query query = session
.createQuery(
"select max(padre.bloqueo)+1 from PadreVO padre")
.setLockMode("padre", LockMode.UPGRADE_NOWAIT);

while (true)
{
try
{
maximo = (Integer) query.uniqueResult();

break;
}
catch (HibernateOptimisticLockingFailureException e)
{
}
}

return maximo;

But I'm getting this exception:

java.lang.IllegalArgumentException: alias not found: padre

If I don't specify the select clause to my HSQL query, then it works great, but obviously don't get the desired result.

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 28, 2005 11:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
It makes zero sense to acquire an UPGRADE lock on a projected entity. You only use upgrade locks for things you are going to update.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 28, 2005 11:47 am 
Beginner
Beginner

Joined: Fri Sep 24, 2004 7:15 am
Posts: 40
I see, but how can I accomplish the objective I'm trying to achieve?


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.