| Summary: | Query parse error when using GROUP BY/HAVING | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Edward Rayl <j.edward.rayl> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | major | ||
| Priority: | P2 | CC: | j.edward.rayl, jamesssss, tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
This bug can be reproduced in 2.3.0 Milestone Build RC2. This bug can be reproduced in 2.3.0 Milestone Build RC3. I can email an Eclipse project containing HR entities and a command line JPQL query tool to the assignee if that would be useful. Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next. The issue seems to be a ReadAllQuery is used for the query, but a ReportQuery is required. JPQL should check the group by and create a ReportQuery. Will fix with Hermes. Fixed in 2.4 The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: 2.2.0 The query below fails to parse correctly. This query is on the Oracle sample schema called HR, with the appropriate entities mapped to it. select d from Department d group by d having COUNT(d.employees1) = 3 with the following SQL output: SQL: SELECT DEPARTMENT_ID, DEPARTMENT_NAME, MANAGER_ID, LOCATION_ID FROM DEPARTMENTS This next query works however: select d, COUNT(d.employees1) from Department d group by d having COUNT(d.employees1) = 3 with the following SQL output: SQL: SELECT t0.DEPARTMENT_ID, t0.DEPARTMENT_NAME, t0.MANAGER_ID, t0.LOCATION_ID, COUNT(t1.EMPLOYEE_ID) FROM DEPARTMENTS t0, EMPLOYEES t1 WHERE (t1.DEPARTMENT_ID = t0.DEPARTMENT_ID) GROUP BY t0.DEPARTMENT_ID, t0.DEPARTMENT_NAME, t0.MANAGER_ID, t0.LOCATION_ID HAVING (COUNT(t1.EMPLOYEE_ID) = ?) The specification should allow the first query. A portion of Section 4.7 of JSR 317: Java Persistence API, Version 2.0 says; The HAVING clause is used to filter over the groups, and can contain aggregate functions over attributes included in the groups and/or functions or other query language operators over the attributes that are used for grouping. It is not required that an aggregate function used in the HAVING clause also be used in the SELECT clause. Reproducible: Always Steps to Reproduce: 1. Create JPA entities for the Oracle HR schema 2. Create a JPQL query as shown above. 3. The result of the query should be one and only one department, not 27