-->
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: java.sql.SQLException: Invalid column index
PostPosted: Thu Mar 15, 2007 4:38 pm 
Newbie

Joined: Thu Mar 08, 2007 1:51 pm
Posts: 4
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 9:52 am 
Newbie

Joined: Thu Mar 08, 2007 1:51 pm
Posts: 4
Does anyone have any insight to this or can I supply any additional information?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 05, 2007 9:31 am 
Newbie

Joined: Thu Apr 05, 2007 9:26 am
Posts: 2
You need to remove the callable="true" attribute from your sql-query element. Putting that there tells hibernate to treat the SQL as a stored procedure call, but your query is just an SQL query.


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.