i have used the aggregate function sum() as follows:
query.append("select oe.name,p.productID,p.partNumber,sum(i.quantity) as quantitysum from products p"
+ " join inventoryitems as i on p.productID = i.productID"
+ " join inventoryowners io on io.inventoryitemid = i.inventoryitemid"
+ " join OEMs as oe on p.OEMID = oe.OEMID
+ " where i.statusCode in ('NEW', 'ACT', 'PHOLD', 'INACT') ");
SQLQuery sqlQuery = currentSession.createSQLQuery(query.toString());
sqlQuery.addScalar("oe.name", Hibernate.STRING);
sqlQuery.addScalar("p.productID", Hibernate.STRING);
sqlQuery.addScalar("p.partNumber", Hibernate.STRING);
sqlQuery.addScalar("quantitysum", Hibernate.INTEGER);
but while executing it i am getting the following exception:-
SQL Error: 0, SQLState: S1000
Unknown type '246 in column 5 of 6 in binary-encoded result set.
when i remove the aggregate function sum() and neccessary scalar from sqlQuery it executes properly
Database:-MySql
Hibernate Version:-3.0
the above query executes properly in MySql
_________________ Thanks and Regards
Rohit
|