persistence@glassfish.java.net

Re: JPQL: fix invalid SQL for simple COUNT DISTINCT query

From: Tom Ware <tom.ware_at_oracle.com>
Date: Tue, 03 Apr 2007 14:06:11 -0400

Hi Michael,

  The code looks good to me. Chris will likely take a quick look when
he is back in the office since he is the expert in this part of the
code, but I believe you should be safe to check-in.

-Tom

Michael Bouschen wrote:

>Hi Tom, hi Chris,
>
>attached you find my fix for issue 2725 "JPA qury error: SELECT
>COUNT(DISTINCT s) FROM Student s"
>(https://glassfish.dev.java.net/issues/show_bug.cgi?id=2725).
>
>The fix requires a change in method
>ReportQuery.prepareObjectAttributeCount, the same method I changed to
>fix the other COUNT issue 2497. The old code handled a COUNT aggregate
>in the SELECT clause only if the COUNT argument was a QueryKeyExpression
>representing a field access. I extended the fix to apply to an
>ExpressionBuilder, too. You find the fix and new test cases attached.
>Please have a look.
>
>Thanks!
>
>Regards Michael
>
>