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
|