Hi Chris, hi Shelly, hi Tom,
thanks for the generated SQL, it shows the problem. The generated SQL
misses the DISTINCT keyword, since the corresponding EJBQL query is a
DISTINCT query:
Select Distinct o.creditCard.balance from Order o
ORDER BY o.creditCard.balance ASC
I also realized that there is a similar problem with aggregate queries
using distinct:
SELECT SUM (DISTINCT o.totalPrice) FROM Order o
Again the generated SQL does not include a DISTINCT.
Actually, this is my fault. I introduced the bug myself when adding
support for multiple expressions in the select clause. You find a fix
for both problems in the attached jar. It includes the sources changes
and the class files, so it can be used as a patch.
Tom,
please have a look at the source code changes. I filed an issue in the
glassfish issue tracker and assingned it to me:
https://glassfish.dev.java.net/issues/show_bug.cgi?id=87
Please use the issue number in the cvs commit message in case you decide
to check in the fix.
Regards Michael
> Hi Michael, Shelly,
>
> The SQL generated is
>
> SELECT t0.BALANCE FROM CREDITCARD_TABLE t0, ORDER_TABLE t1 WHERE
> (t0.FK_FOR_ORDER_TABLE = t1.ID) ORDER BY t0.BALANCE ASC
> and when run outside of toplink on the database (after the test was run)
> does return the same results:
>
> 400
> 500
> 750
> 1000
> 1000
> 1400
> 1500
> 2000
> 2500
> 4400
> 5000
> 5500
> 7000
> 7400
> 8000
> 9500
> 13000
> 15000
> 23000
>
> I'll check the setup, but it looks like the test needs to be changed so
> it has this as the expected results.
>
>
> Best Regards,
> Chris
>
>