jtblair wrote:
In your generated SQL, there is a sum() while in your Hibernate query, there is an avg(). Can you have a double check?
HTH,
JB
Sorry, that's right. I've tried with all aggregate functions, without any luck, and the sample is from different runs. I've been struggling with this most annoying problem for a day, just to boil the problem down to simple timestamp arithmetic.
Here is another much simpler sample, in HSQL:
Code:
select ai.closeDate - ai.creationDate from xxx.ActionItem as ai
the generated SQL
Code:
select actionitem0_.CLOSE_DATE-actionitem0_.CREATION_DATE as col_0_0_ from ITQUEUE.ACTION_ITEM actionitem0_
with the generated expression:
Code:
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at xxx.execute(Report.java:91)
... 71 more
Caused by: COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] CLI0102E Invalid conversion. SQLSTATE=07006
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)
at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2ResultSet.getTimestamp2(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2ResultSet.getTimestamp(Unknown Source)
at COM.ibm.db2.jdbc.app.DB2ResultSet.getTimestamp(Unknown Source)
at com.ibm.ws.rsadapter.jdbc.WSJdbcResultSet.getTimestamp(WSJdbcResultSet.java:1993)
at org.hibernate.type.TimestampType.get(TimestampType.java:28)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:77)
at org.hibernate.type.NullableType.nullSafeGet(NullableType.java:68)
at org.hibernate.loader.hql.QueryLoader.getResultColumnOrRow(QueryLoader.java:352)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:329)
at org.hibernate.loader.Loader.doQuery(Loader.java:412)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
... 77 more
As I see the JIRA ticket, it might actually be fixed in 3.1. I'll try to have a go on that to see, but won't be able to use it until stable 3.1 is released.
Isn't there a workaround we could use? (Our big problem, is, that the HSQL query is generated from a report definition and the result list is fed straight to JasperReports, there is no way we could modify the resulting dataset in between.)[/code]