Bug with aggregate functions

Description

When executing the following query:

SELECT DebtorInvoice.debt.id , InvoiceLink.notice.noticeNumber , COUNT ( DISTINCT Account.id) , DebtorInvoice.account.number , AssociatedNotice.noticeDate , NotionalCredit.account.id , Min(ScheduledObligation.onOrBeforeDate) , DebtorInvoice.recordedTimestamp , Debt.joint , Lines.balance.amount , Debt.joint , Lines.balance.amount , Debt.joint , Lines.balance.unallocated , Debt.joint , Lines.balance.unallocated , Min(ScheduledObligation.onOrBeforeDate) FROM au.com.dytech.find.core.business.model.accounts.DebtorInvoice AS DebtorInvoice Inner join DebtorInvoice.debt AS Debt Inner join Debt.lines AS Lines,au.com.dytech.find.core.business.model.notices.Notice AS AssociatedNotice,au.com.dytech.find.core.business.model.accounts.Schedule AS Schedule,au.com.dytech.find.core.business.model.accounts.NotionalCredit AS NotionalCredit,au.com.dytech.find.core.business.model.accounts.InvoiceLink AS InvoiceLink,au.com.dytech.find.core.business.model.accounts.Account AS Account,au.com.dytech.find.core.business.model.accounts.DebtorInvoice AS Invoices,au.com.dytech.find.core.business.model.accounts.ScheduledObligation AS ScheduleObligation,au.com.dytech.find.core.business.model.accounts.TransactionChange AS TransactionChange WHERE ScheduledObligation.balance.amount <> 0 AND TransactionChange.auditee = DebtorInvoice AND DebtorInvoice.schedule = Schedule AND Invoices.debt = Debt AND DebtorInvoice.invoiceLink = InvoiceLink AND InvoiceLink.notice = AssociatedNotice AND Invoices.account = Account AND Lines.notionalCredit = NotionalCredit AND Schedule.obligations = ScheduledObligation GROUP BY Debt.joint , Lines.balance.amount , Debt.joint , Lines.balance.unallocated , Debt.joint , Lines.balance.amount , DebtorInvoice.account.number , AssociatedNotice.noticeDate , DebtorInvoice.recordedTimestamp , DebtorInvoice.debt.id , InvoiceLink.notice.noticeNumber , NotionalCredit.account.id , Debt.joint , Lines.balance.unallocated

gives the following error:

Caused by: java.lang.IllegalStateException: No data type for node: org.hibernate.hql.ast.tree.AggregateNode
+-[AGGREGATE] AggregateNode: 'Min'

at org.hibernate.hql.ast.tree.SelectClause.initializeExplicitSelectClause(SelectClause.java:139)
at org.hibernate.hql.ast.HqlSqlWalker.useSelectClause(HqlSqlWalker.java:603)
at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:465)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:643)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:279)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:227)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:216)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:156)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:103)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:72)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:52)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:108)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:88)
at au.com.dytech.find.hibernateetl.impl.HQLCreatorImpl.getHQLQuery(HQLCreatorImpl.java:80)
... 3 more

Upon closer inspection it appears the first Min function: Min(ScheduledObligation.onOrBeforeDate) does not have the down AST node populated with ScheduledObligation.onOrBeforeDate as I would have expected.

This was not an issue in Hibernate 3.0.5.

Environment

Oracle database

Assignee

Unassigned

Reporter

rerr

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure