Hi,
I tried the following jpql on openjpa trunk code:
String jpql1 = "SELECT k.keyname, SUM(k.keyval) FROM KeyGenEntity k
GROUP BY k.keyname ORDER BY SUM(k.keyval) DESC";
The generated sql is:
SELECT t0.KEYNAME, SUM(t0.KEYVAL), SUM(t0.KEYVAL) FROM KEYGEN t0 GROUP BY
t0.KEYNAME ORDER BY SUM(t0.KEYVAL) DESC
It works just fine. Can you try the trunk code?
Regards,
Fay
----- Original Message ----
From: jonathan de beir <[email protected]>
To: [email protected]
Sent: Thu, April 1, 2010 6:24:15 AM
Subject: aggregates in ORDER BY
Hello,
I have the problem in OpenJPA v1.2.2 that aggregates in order by clauses
doesn't works, altough it was fixed in version 1.1.0:
https://issues.apache.org/jira/browse/OPENJPA-490?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
Jpql query giving the problem:
SELECT b.cid, SUM(b.distance) FROM BestDistance b GROUP BY b.cid ORDER BY
SUM(b.distance) DESC
Working MySQL query with same functionality:
SELECT cid, SUM(distance) FROM bestdistances GROUP BY cid ORDER BY
SUM(distance) DESC
This is a warning I get:
WARN [http-thread-pool-8080-(1)] openjpa.Query - This JPQL query uses
non-standard OpenJPA extensions in the ORDER BY clause. JPQL string: "SELECT
b.cid, SUM(b.distance) FROM BestDistance b GROUP BY b.cid ORDER BY
SUM(b.distance) DESC". Query execution will proceed. The
openjpa.Compatibility configuration setting is configured to log a warning
the first time a given extended query is encountered.
To me it looks like the issue wasn't fixed, altough I'm kinda new with
OpenJPA / JPQL.
Can someone clear it out for me?
Greetings, Jonathan