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