-->
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.  [ 1 post ] 
Author Message
 Post subject: problem using createSQLQuery()
PostPosted: Tue Nov 23, 2004 6:58 am 
Newbie

Joined: Sat Jan 24, 2004 8:58 am
Posts: 4
Location: Bangladesh
hi all,
hope all are well.

i'm facing following problem.

problem to use session.createSQLQuery()
its giving java.sql.SQLException invalid column name, but all of my columns and mappings are OK.
The SQL which is generated by Hibernate gives proper output when i execute this generated SQL in ORACLE SQL prompt.

full description of problem 1 is given below.

Hibernate version: hibernate 2.1.1

Mapping documents:

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="ibbl.common.dl.po.AccountPO" table="t_account">
<id name="oid" column="oid" type="string">
<generator class="assigned">
</generator>
</id>
<property name="accNo" column="acc_no" type="string"/>
<property name="accTitle" column="acc_title" type="string"/>
</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

session = sessionFactory.openSession();

String tmpqs = "select {AccountPO}.acc_no as {AccountPO.accNo}, " +
" {AccountPO}.acc_title as {AccountPO.accTitle} " +
" from T_ACCOUNT {AccountPO} " +
" where {AccountPO}.acc_type = '06' ";

String alias1 = "AccountPO";
Class clName1 = ibbl.common.dl.po.AccountPO.class;

List list = session.createSQLQuery(tmpqs,alias1,clName1).list();

if (list!=null && list.size()>0)
{
AppLogger.print("found something");
}
session.close();

Full stack trace of any exception that occurs:
10265 [main] ERROR util.JDBCExceptionReporter - Invalid column name
10265 [main] WARN util.JDBCExceptionReporter - SQL Error: 17006, SQLState: null
10281 [main] ERROR util.JDBCExceptionReporter - Invalid column name
10281 [main] ERROR util.JDBCExceptionReporter - SQLException occurred
java.sql.SQLException: Invalid column name
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:285)
at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:5278)
at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:698)
at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1505)
at net.sf.hibernate.type.StringType.get(StringType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:351)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:202)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:132)
at net.sf.hibernate.loader.Loader.doList(Loader.java:949)
at net.sf.hibernate.loader.Loader.list(Loader.java:940)
at net.sf.hibernate.loader.SQLLoader.list(SQLLoader.java:92)
at net.sf.hibernate.impl.SessionImpl.findBySQL(SessionImpl.java:3628)
at net.sf.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:52)
at ibbl.common.dl.SBSDL.processSBS(SBSDL.java:189)
at ibbl.common.dl.SBSDL.main(SBSDL.java:324)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.intellij.rt.execution.application.AppMain.main(Unknown Source)

Name and version of the database you are using: ORACLE 9

The generated SQL (show_sql=true):

Hibernate: select AccountPO.acc_no as acc_no0_, AccountPO.acc_title as acc_title0_ from T_ACCOUNT AccountPO where AccountPO.acc_type = '06'

Debug level Hibernate log excerpt:

[/b]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.