Hi Michael,
Chris and I have both look and we think the fix is good.
Go ahead and check in.
-Tom
Michael Bouschen wrote:
>Hi Tom,
>
>I looked into issue 2496 "JPQL: constructor query using COUNT results in
>SQLException": https://glassfish.dev.java.net/issues/show_bug.cgi?id=2496
>
>The issue is that the generated SQL misses a COUNT argument, if the
>COUNT is counting a a joined variable and the COUNT is an argument of a
>constructor expression, e.g.
> SELECT NEW test.pojo.CustomerDetail(c.name, COUNT(o)) FROM Customer c
>JOIN c.orders o GROUP BY c.name
>Method ReportQuery.prepareObjectAttributeCount iterates the SELECT
>expressions of a ReportQuery in order to execute some special handling
>for COUNT aggregates in the SELECT clause. I extended the method to
>iterate the constructor arguments in case of a constructor expression.
>This makes sure we generate the same SQL whether there is a constructor
>expression or not. You find my ReportQuery changes and a new test method
>attached. Please have a look.
>
>Thanks!
>
>Regards Michael
>
>