-->
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(): alias?
PostPosted: Thu May 12, 2005 10:40 am 
Newbie

Joined: Tue May 10, 2005 10:17 am
Posts: 6
I'm using Hibernate 3.0.3 with Oracle 10g.

I try to build a HQL-Query which locks the loaded objects. My approach looks like that:

Code:
      Query q = session.createQuery("FROM Test as test where attr = 'test');
      q.setCacheMode(CacheMode.IGNORE);
      q.setFetchSize(this.fetchSize);
      q.setLockMode("test", LockMode.UPGRADE_NOWAIT);
       
      ScrollableResults results = q.scroll(ScrollMode.FORWARD_ONLY);
      ...


However, it does not work. The problem is the setting of the query's lock-mode. I get exceptions about "BadSqlGrammar" when using it like that.

java.sql.SQLException: ORA-00933: SQL command not properly ended

at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:158)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:305)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:272)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:623)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:181)
at oracle.jdbc.driver.T4CPreparedStatement.execute_for_describe(T4CPreparedStatement.java:509)
at oracle.jdbc.driver.OracleStatement.execute_maybe_describe(OracleStatement.java:979)
at oracle.jdbc.driver.T4CPreparedStatement.execute_maybe_describe(T4CPreparedStatement.java:552)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1096)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3018)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3059)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:118)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1239)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1219)
at org.hibernate.loader.Loader.scroll(Loader.java:1603)
at org.hibernate.loader.hql.QueryLoader.scroll(QueryLoader.java:422)
at org.hibernate.hql.ast.QueryTranslatorImpl.scroll(QueryTranslatorImpl.java:291)
at org.hibernate.impl.SessionImpl.scroll(SessionImpl.java:956)
at org.hibernate.impl.QueryImpl.scroll(QueryImpl.java:62)



When I use "Test" as parameter I get this:
java.lang.NullPointerException
at org.hibernate.sql.ForUpdateFragment.<init>(ForUpdateFragment.java:55)
at org.hibernate.loader.hql.QueryLoader.applyLocks(QueryLoader.java:314)
at org.hibernate.loader.Loader.preprocessSQL(Loader.java:181)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1120)
at org.hibernate.loader.Loader.scroll(Loader.java:1602)
at org.hibernate.loader.hql.QueryLoader.scroll(QueryLoader.java:422)
at org.hibernate.hql.ast.QueryTranslatorImpl.scroll(QueryTranslatorImpl.java:291)
at org.hibernate.impl.SessionImpl.scroll(SessionImpl.java:956)
at org.hibernate.impl.QueryImpl.scroll(QueryImpl.java:62)



What am I expected to set as the alias parameter?

Thanks in advance,
Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 17, 2005 4:27 am 
Newbie

Joined: Tue May 10, 2005 10:17 am
Posts: 6
An addition: Meanwhile I tried to resort to a Criteria query. In that case I could omit the alias. However, the result has been the same.

It would really be appreciated if someone could shed some light on this.

Regards,
Andreas


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 17, 2005 5:27 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Maybe similar problem: http://forum.hibernate.org/viewtopic.php?t=942454 ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 17, 2005 6:26 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
No, not a similar problem at all.

You of course need to show the actual generated SQL that Oracle didn't like if you want us to be able to help you.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 17, 2005 6:53 am 
Newbie

Joined: Tue May 10, 2005 10:17 am
Posts: 6
I just debugged the code to where the exception gets thrown.
I found out that the statement itself seems not to be the problem, for I can execute it manually.

However, the error message states "could not execute query using scroll". As I am using Spring to access hibernate, that message got lost and I had only the underlying SQL statement. I will file a request there to keep HibernateException (or at least informations therein) in the stacktrace.

So do I understand it correctly that I cannot use SELECT FOR UPDATE (i.e. LockMode.UPGRADE_NOWAIT) in combination with scrolling?

Regards,
Andreas


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.