-->
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: HQL Problem
PostPosted: Fri Mar 18, 2005 2:47 pm 
Newbie

Joined: Mon Jun 07, 2004 12:59 pm
Posts: 13
Hibernate version: 2.1.8

Name and version of the database you are using: MySQL 4.0.22

Can anyone tell me why the following HQL succeeds but when I change the '+' to a '*' it fails?

select cust.fname, cust.lname, prod.description, sum(ordl.quantity + prod.unitPrice) from PrivateCustomer cust
left join cust.orders ords
left join ords.orderline ordl
left join ordl.product prod where ords.id > 0
group by cust.fname, prod.description

The generated SQL and exception are as follows (note that Column x4_0_ is not generated in the SQL ):

[java] Hibernate: select privatecus0_.FNAME as x0_0_, privatecus0_.LNAME as x1_0_, product3_.DE
SCRIPTION as x2_0_, sum(orderline2_.QUANTITY*product3_.UNIT_PRICE) as x3_0_ from CUSTOMER privatecus
0_ left outer join ORDERS orders1_ on privatecus0_.CUST_ID=orders1_.CUST_ID left outer join ORDERLIN
E orderline2_ on orders1_.ORDER_ID=orderline2_.ORDER_ID left outer join PRODUCT product3_ on orderli
ne2_.PROD_ID=product3_.PROD_ID where privatecus0_.CUSTOMER_TYPE='SS' and ((orders1_.ORDER_ID>0 )) gr
oup by privatecus0_.FNAME , product3_.DESCRIPTION
[java] Could not execute query
[java] net.sf.hibernate.exception.GenericJDBCException: Could not execute query
[java] at net.sf.hibernate.exception.ErrorCodeConverter.handledNonSpecificException(ErrorCo
deConverter.java:90)
[java] at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:79)

[java] at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:3
0)
[java] at net.sf.hibernate.impl.SessionImpl.convert(SessionImpl.java:4110)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1556)
[java] at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
[java] at org.mnsu.edu.oes.TestCust.main(Unknown Source)
[java] Caused by: java.sql.SQLException: Column 'x4_0_' not found.
[java] at com.mysql.jdbc.ResultSet.findColumn(ResultSet.java:2316)
[java] at com.mysql.jdbc.ResultSet.getInt(ResultSet.java:1287)
[java] at net.sf.hibernate.type.IntegerType.get(IntegerType.java:21)
[java] at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
[java] at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
[java] at net.sf.hibernate.hql.QueryTranslator.getResultColumnOrRow(QueryTranslator.java:10
05)
[java] at net.sf.hibernate.loader.Loader.getRowFromResultSet(Loader.java:238)
[java] at net.sf.hibernate.loader.Loader.doQuery(Loader.java:281)
[java] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java
:133)
[java] at net.sf.hibernate.loader.Loader.doList(Loader.java:1033)
[java] at net.sf.hibernate.loader.Loader.list(Loader.java:1024)
[java] at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:854)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1553)

TIA
Allan M. Hart


Top
 Profile  
 
 Post subject: This is a known bug, number HB-34.
PostPosted: Fri Mar 18, 2005 8:32 pm 
Beginner
Beginner

Joined: Mon Mar 14, 2005 6:07 pm
Posts: 36
This is a known bug number HB-34. Actually, there were other bugs filed for the same issue, but they were all closed.


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.