Hi.
I am trying to run a sql-query to try it out and keep getting the error:
"java.sql.SQLException: Invalid column index"
I have turned on Hibernate DEBUG and searched all over the internet and have found nothing. I am using the Oracle JDBC ojdbc14_g.jar. When i run the same query with : SQLQuery sq = sessionFactory.getCurrentSession().createSQLQuery("SELECT LOGIN_CODE AS loginId, FIRST_NAME AS firstName FROM users"); I do not get an error.
Ideas?
Test JAVA:
Query q = HibernateUtil.currentSession().getNamedQuery("getUsers");
Iterator it = q.list().iterator();
XML:
<hibernate-mapping package="XXXX" default-access="field">
<sql-query name="getUsers" callable="true">
<![CDATA[SELECT LOGIN_CODE AS loginId, FIRST_NAME AS firstName FROM users]]>
</sql-query>
...OR....
<sql-query name="getUsers" callable="true">
<return-scalar column="firstName" type="string"/>
<return-scalar column="loginId" type="string"/>
<![CDATA[SELECT LOGIN_CODE AS loginId, FIRST_NAME AS firstName FROM users]]>
</sql-query>
</hibernate-mapping>
DEBUG:
15:30:28,279 DEBUG SessionImpl:220 - opened session at timestamp: 11739906282
15:30:28,279 DEBUG QueryPlanCache:118 - located native-sql query plan in cache (SELECT LOGIN_CODE AS loginId, FIRST_NAME AS firstName FROM users)
15:30:28,279 DEBUG SessionImpl:1685 - SQL query: SELECT LOGIN_CODE AS loginId, FIRST_NAME AS firstName FROM users
15:30:28,279 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
15:30:28,279 DEBUG ConnectionManager:419 - opening JDBC connection
15:30:28,279 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
15:30:28,279 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0
15:30:28,279 DEBUG SQL:393 - SELECT LOGIN_CODE AS loginId, FIRST_NAME AS firstName FROM users
Hibernate: SELECT LOGIN_CODE AS loginId, FIRST_NAME AS firstName FROM users
15:30:28,279 DEBUG AbstractBatcher:476 - preparing statement
15:30:28,373 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
15:30:28,373 DEBUG AbstractBatcher:525 - closing statement
15:30:28,373 DEBUG JDBCExceptionReporter:69 - could not execute query [SELECT LOGIN_CODE AS loginId, FIRST_NAME AS firstName FROM users]
java.sql.SQLException: Invalid column index
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:166)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:217)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:325)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterInternal(OracleCallableStatement.java:160)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:407)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:556)
at org.hibernate.dialect.Oracle9Dialect.registerResultSetOutParameter(Oracle9Dialect.java:278)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1551)
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:2211)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
at org.hibernate.loader.Loader.list(Loader.java:2090)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at test.main(test.java:37)
15:30:28,373 WARN JDBCExceptionReporter:77 - SQL Error: 17003, SQLState: null
15:30:28,373 ERROR JDBCExceptionReporter:78 - Invalid column index
15:30:28,373 DEBUG JDBCContext:233 - after autocommit
15:30:28,373 DEBUG ConnectionManager:402 - aggressively releasing JDBC connection
15:30:28,373 DEBUG ConnectionManager:439 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
15:30:28,373 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2214)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2095)
at org.hibernate.loader.Loader.list(Loader.java:2090)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)
at test.main(test.java:37)
Caused by: java.sql.SQLException: Invalid column index
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:166)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:217)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:325)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameterInternal(OracleCallableStatement.java:160)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:407)
at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:556)
at org.hibernate.dialect.Oracle9Dialect.registerResultSetOutParameter(Oracle9Dialect.java:278)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1551)
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:2211)
... 7 more
|