Hi Tom, hi Chris,
attached you find an updated version of my fix. Chris proposed to use
the old code that generates a COUNT(*) with a an EXISTS subquery in case
of a COUNT(DISTINCT o) where the class of the variable o has a composite
PK and the variable o is defined as inner join. Now my code throws an
exception only if the variable is defined in a OUTER JOIN and the class
has a composite PK and COUNT DISTINCT is used. Please have a look.
Thanks!
Regards Michael
> Hi Tom,
>
> attached you find my fix for issue 2497 "JPQL: Invalid SQL for COUNT
> on joined variable"
> (https://glassfish.dev.java.net/issues/show_bug.cgi?id=2497). It
> changes the generated SQL for queries such as:
> SELECT c.name, COUNT(o) FROM Customer c LEFT JOIN c.orders o GROUP BY
> c.name
>
> My change fixes the issue if the class of the joined variable has a
> single PK or if it is not a COUNT(DISTINCT o). It does not cover the
> case of a COUNT(DISTINCT o) where the class of the variable o has a
> composite PK. I propose I checkin the fix, resolve issue 2497 and file
> a new P4 issue for the remaining case from above.
>
> You find the fix and new test cases attached. Please have a look.
>
> Thanks!
>
> Regards Michael