-->
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: [MySQL5] Coulmn NOT found error.
PostPosted: Tue Jan 10, 2006 3:03 pm 
Newbie

Joined: Wed Dec 07, 2005 11:09 pm
Posts: 4
Location: SF Bay area
Guys,
I am using hibernate3 with MySQL 5 on windows. I have a simple SQL query,
List person=session.createSQLQuery("SELECT MAX(x.orderId) FROM PurchaseOrder {x}").addEntity(PurchaseOrderHIB.class).list();

The mapping is,
<class name="PurchaseOrderHIB" table="PurchaseOrder">
<id name="orderId" column="orderId">
<generator class="assigned"/>

The SQL query executes fine inside the MySQL console.

But when i try to execute the same query in my code, i am getting a column not found exception. The stack trace is below: Any idea?

Thanks,
-Uday.

10:52:45,690 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
10:52:45,700 DEBUG SQL:346 - select max(PurchaseOrder.orderId) from PurchaseOrder
Hibernate: select max(PurchaseOrder.orderId) from PurchaseOrder
10:52:45,700 DEBUG AbstractBatcher:424 - preparing statement
10:52:45,700 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
10:52:45,710 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
10:52:45,720 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
10:52:45,720 DEBUG AbstractBatcher:470 - closing statement
10:52:45,730 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: S0022
10:52:45,730 ERROR JDBCExceptionReporter:72 - Column 'orderId' not found.
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2150)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2026)
at org.hibernate.loader.Loader.list(Loader.java:2021)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:109)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1475)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:121)


Top
 Profile  
 
 Post subject: bug in hibernate?
PostPosted: Tue Jan 10, 2006 7:42 pm 
Newbie

Joined: Wed Dec 07, 2005 11:09 pm
Posts: 4
Location: SF Bay area
I corrected the SQL:
List person=session.createSQLQuery("SELECT MAX(x.orderId) as {x.orderId} FROM PurchaseOrder x").addEntity("x",PurchaseOrderHIB.class).list();

But it says some other column is not found in the database:
15:35:16,744 DEBUG AbstractBatcher:424 - preparing statement
15:35:16,744 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
15:35:16,754 DEBUG LongType:123 - returning '2' as column: orderId1_0_
15:35:16,784 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
15:35:16,784 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
15:35:16,794 DEBUG AbstractBatcher:470 - closing statement
15:35:16,794 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: S0022
15:35:16,794 ERROR JDBCExceptionReporter:72 - Column 'orderDate1_0_' not found.
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)

---------------xxx----------
The question i have is:
[1]Why is it trying to query my other column "orderDate"?

[2]Then it is trying to query with the modified column, so this exception.

any pointers?


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.