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: Error with SELECT... FOR UPDATE
PostPosted: Thu Aug 03, 2006 8:48 am 
Newbie

Joined: Thu Aug 03, 2006 8:30 am
Posts: 4
On Oracle you can do this:
SELECT object.ID FROM TABLE object FOR UPDATE OF object.ID
giving you back the id and locking lines.

But with Hibernate it's not working.
Query q = session.createQuery("SELECT object.ID FROM TABLE object");
q.setLockMode("object",LockMode.UPGRADE);
q.list();
This code generate the following error:
Exception in thread "Thread-0" java.lang.IllegalArgumentException: alias not found: obj
at org.hibernate.loader.hql.QueryLoader.applyLocks(QueryLoader.java:299)
at org.hibernate.loader.Loader.preprocessSQL(Loader.java:189)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1552)
at org.hibernate.loader.Loader.doQuery(Loader.java:661)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)

What's working actually :
Query q = session.createQuery("SELECT object FROM TABLE object");
q.setLockMode("object",LockMode.UPGRADE);
q.list();


Does anyone know how to make this work?

thanks for help


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 4:49 am 
Newbie

Joined: Thu Aug 03, 2006 8:30 am
Posts: 4
any clue?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 04, 2006 5:51 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
It could be because in the first query you are selecting specific columns and in that case Hiberate does'nt select the entire row (i.e. the persisitent class) but returns them as an Object array.

In the second case since you are referring the entire row it is probably working.


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.