This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 350597 - JPA 2.1 Arithmetic expressions with Sub-Queries, option support for select and from clause subqueries
Summary: JPA 2.1 Arithmetic expressions with Sub-Queries, option support for select an...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL: http://wiki.eclipse.org/EclipseLink/D...
Whiteboard:
Keywords:
Depends on:
Blocks: 338610
  Show dependency tree
 
Reported: 2011-06-28 11:19 EDT by Gordon Yorke CLA
Modified: 2022-06-09 10:35 EDT (History)
3 users (show)

See Also:


Attachments
Adds Expression support for sub-selects in the SELECT from FROM clauses (130.71 KB, patch)
2011-10-24 10:31 EDT, James Sutherland CLA
no flags Details | Diff
fix to FROM sub-selects (37.81 KB, patch)
2012-04-19 10:06 EDT, James Sutherland CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Gordon Yorke CLA 2011-06-28 11:19:13 EDT
In previous versions of the specification Sub-Queries were not allowed in math expressions in JPQL.  In 2.1 the JPQL BNF will be updated to allow subqueries in math expressions.

   select e from Employee e where e.salary > (select avg(emp.salary) from Employee emp where emp.managedEmployee is not empty)
Comment 1 Gordon Yorke CLA 2011-06-28 11:20:49 EDT
The BNF has changed to allow the SubQuery in may places in the statement so care must be taken to ensure it is supported throughout the WHERE and HAVING clauses.

Although the BNF will allow SubQueries in the SELECT and FROM clauses this is not required by the specification
Comment 2 James Sutherland CLA 2011-10-24 10:31:56 EDT
Created attachment 205826 [details]
Adds Expression support for sub-selects in the SELECT from FROM clauses
Comment 3 James Sutherland CLA 2011-10-24 11:24:30 EDT
SVN trunk commit: Bug#350597  sub-selects in SELECT, FROM clause

Added support to Expression for sub-selects in the SELECT and FROM clauses.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=350597

http://wiki.eclipse.org/EclipseLink/DesignDocs/312146

Code review:  Andrei (pending)

Changes:
- Added getTable(Expression) to Expression.
- Moved getContainingDescriptor() up to DataExpression and chnaged code to use it.
- Added clonedExpression to ExpressionNormalizer to keep track of identity.
- Avoided duplicate normalization in reusable expressions.
- Added FromAliasExpression to allow query key like usage on FROM clause sub-selects.
- Added FromSubSelectExpression to allow sub-selects in the FROM clause, treated as TableExpressions.
- Added SubSelectDatabaseTable to allow sub-selects to be treated as table and printed in the FROM clause.
- Added support for print SubSelectExpression in select clause.
- Fixed issue of ReportQuery items using rebuild instead of copy.
- Fixed mappingCriteria to take the base to ensure the mapping expression is twisted with the correct base.
- Changed logging to log the category.
- Fixed ReportQuery to copy having clause.
- Fixed SchemaManager to reset database event listeners after creating tables.
- Added some @Overrides, some cleanup
- Added sub-select FROM and SELECT clause tests to expression subs-selects core test suite.
- Got Stephen Mcritchie's infamous ParallelCorrelatedSubSelectsTest working finally.
- Changed expression tests to unprepare in setup so they can be re-run.
- Added JPA JPQL test for sub-select in the HAVING clause and sue with comparison operators.
Comment 4 James Sutherland CLA 2012-02-06 14:25:26 EST
Support for subs-selects added in Hermes JPQL
Comment 5 James Sutherland CLA 2012-04-19 10:06:01 EDT
Created attachment 214250 [details]
fix to FROM sub-selects
Comment 6 James Sutherland CLA 2012-04-23 09:47:02 EDT
SVN trunk commit: Bug#350597 - FROM sub-selects

https://bugs.eclipse.org/bugs/show_bug.cgi?id=350597

Code review: Andrei (pending)

Changes:
-	Added core test for FROM sub-selects with aggregation functions.
-	Excluded union tests from Sybase as it does not support intersect.
-	Renamed Expression as to treat (deprecated as(Class)).
-	Added as(String) Expression support for SQL SELECT AS option.
-	Fixed FromAliasExpression to work with functions.
-	Fixed FromSubSelectExpression normalize to use AS for functions.
-	Added TableExpression to allow TABLE operator.
Comment 7 James Sutherland CLA 2012-05-28 09:57:36 EDT
fixed
Comment 8 Eclipse Webmaster CLA 2022-06-09 10:35:02 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink