-->
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.  [ 2 posts ] 
Author Message
 Post subject: Help with SQL query
PostPosted: Mon Jan 19, 2004 5:04 pm 
Beginner
Beginner

Joined: Tue Nov 18, 2003 12:34 am
Posts: 39
Location: Dallas, Texas, US
Hi,
I recently started using the SQL query and run in the following trouble.

EXCEPTION:
========
java.sql.SQLException: Bad column name: TEST_ID0_
at com.quadcap.sql.ItemsCursor.<init>(ItemsCursor.java:90)
at com.quadcap.sql.SelectExpression.getCursor(SelectExpression.java:227)
at com.quadcap.sql.SelectStmt.execute(SelectStmt.java:76)
at com.quadcap.sql.Session.doStatement(Session.java:264)
at com.quadcap.jdbc.PreparedStatement.execute(PreparedStatement.java:186)
at com.quadcap.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:223)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:83)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:794)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:188)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.jav

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)

MAPPING:
=======
<class
name="eg.StudentTest"
table="Table1"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="id"
column="Test_ID"
type="int"
unsaved-value="any"
>
<generator class="assigned">
</generator>
</id>
...

JAVA SOURCE:
=========
Query sqlQuery = session.createSQLQuery("select {test.id} from TABLE1 as {test}", "test", StudentTest.class)

I think it is reading the mapped column name as "Test_ID0_" instead of "Test_ID"... Ultimately, I want to do a aggregate sum(test.id)...

If I am doing something wrong, please help with that. I greatly appreciate your time.

Madhan.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 6:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
read the docs and examples about createsqlquery!

You need to provide the columns name your self and map them to the aliases (those embeded in {'s and }'s)

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.