Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/DesignDocs/312146"

Line 62: Line 62:
 
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=357843 dot removes outer join]
 
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=357843 dot removes outer join]
 
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=275449 is not null should be used]
 
* [https://bugs.eclipse.org/bugs/show_bug.cgi?id=275449 is not null should be used]
 +
* [ from clause not used in select or where is omitted]
  
 
= Concepts =
 
= Concepts =
Line 81: Line 82:
  
 
= Functionality =
 
= Functionality =
 
+
* Extend ObjectExpression to support an onClause, must normalize and copy expression accordingly.
 +
* Allow ExpressionBuilders to be added to nonFetchJoinExpressions in ObjectLevelReadQuery.
  
 
= Testing =
 
= Testing =
 
+
ON clause needs Expression tests in core testing and JPQL tests in JPA testing.
 +
Testing both 1-1, 1-m, relationship and parallel.
  
 
= API =
 
= API =
 
+
JPQL
 +
* Select e from Employee e left join e.address a on (a.city = 'Ottawa')
 +
* Select e from Employee e left join Project p on (p.teamLeader = e)
  
  
 
= Native API =
 
= Native API =
 +
* Expression
 +
** on(Expression onClause)
 +
* ObjectLevelReadQuery
 +
** addNonFetchJoin(Expression)
 +
** addLeftNonFetchJoin(Expression)
  
 +
Examples:
 +
<source lang="java">
 +
ExpressionBuilder employee = new ExpressionBuilder();
 +
Expression address = employee.getAllowingNull("address");
 +
address.on(address.get("city").equal("Ottawa"));
 +
ReadAllQuery query = new ReadAllQuery(Employee.class, employee);
 +
query.addNonFetchJoin(address);
 +
 +
ExpressionBuilder employee = new ExpressionBuilder(Employee.class);
 +
ExpressionBuilder project = new ExpressionBuilder(Project.class);
 +
project.on(project.get("teamLeader").equal(employee));
 +
ReadAllQuery query = new ReadAllQuery(Employee.class, employee);
 +
query.addNonFetchJoin(project);
 +
</source>
  
 
= Config files =
 
= Config files =
Line 97: Line 121:
  
 
= Documentation =
 
= Documentation =
 
+
Need to document our BNF, example queries and support beyond JPA 2.0/2.1 in query section.
  
 
= Open Issues  =
 
= Open Issues  =
Line 125: Line 149:
 
= Future Considerations =
 
= Future Considerations =
 
* Other JPQL enhancements.
 
* Other JPQL enhancements.
 +
* Criteria support.

Revision as of 14:01, 4 October 2011

Design Specification: Enhanced JPQL

ER 312146

Feedback

Document History

Date Author Version Description & Notes
2011-10-04 James 0.1 Draft

Project overview

JPQL currently offers a sub-set of SQL functionality. Some queries that are possible using SQL cannot be defined using JPQL.

It is desired to make EclipseLink's JPQL support be more complete of what is possible in SQL.

A key requirement from users (#1 voted enhancement) is to have ON clause support in JPQL.

Other missing features of SQL could also be added to JPQL, such as sub selects in the SELECT from FROM clauses, and enhanced function support.

Other JPQL enhancements:

Other JPQL bugs:

Concepts

ON clause : the SQL clause part of the FROM clause that defines how to tables are joined, this can be used for both joins and outer joins, but is required for outer joins.

outer join : A join where if a row in the source table has no joined rows in the target table it is still included in the join result with a null row for the target table.

ANTRL : Third party library currently used in EclipseLink for parsing JPQL.

Hermes : New JPQL parser developed by Dali project for parsing JPQL at design time. Currently included in EclipseLink SVN, but not currently used.

Requirements

  • Support additional ON clause for a relationship join.
  • Support an ON clause on the join for two independent objects.

Design Constraints

  • Outer join capabilities differ in different databases.
  • SQL capabilities differ in different databases.

Functionality

  • Extend ObjectExpression to support an onClause, must normalize and copy expression accordingly.
  • Allow ExpressionBuilders to be added to nonFetchJoinExpressions in ObjectLevelReadQuery.

Testing

ON clause needs Expression tests in core testing and JPQL tests in JPA testing. Testing both 1-1, 1-m, relationship and parallel.

API

JPQL

  • Select e from Employee e left join e.address a on (a.city = 'Ottawa')
  • Select e from Employee e left join Project p on (p.teamLeader = e)


Native API

  • Expression
    • on(Expression onClause)
  • ObjectLevelReadQuery
    • addNonFetchJoin(Expression)
    • addLeftNonFetchJoin(Expression)

Examples:

ExpressionBuilder employee = new ExpressionBuilder();
Expression address = employee.getAllowingNull("address");
address.on(address.get("city").equal("Ottawa"));
ReadAllQuery query = new ReadAllQuery(Employee.class, employee);
query.addNonFetchJoin(address);
 
ExpressionBuilder employee = new ExpressionBuilder(Employee.class);
ExpressionBuilder project = new ExpressionBuilder(Project.class);
project.on(project.get("teamLeader").equal(employee));
ReadAllQuery query = new ReadAllQuery(Employee.class, employee);
query.addNonFetchJoin(project);

Config files

Documentation

Need to document our BNF, example queries and support beyond JPA 2.0/2.1 in query section.

Open Issues

Issue # Owner Description / Notes
1 Which JPQL parser should be used ANTLR or Hermes?

Decisions

Issue Description / Notes Decision

Future Considerations

  • Other JPQL enhancements.
  • Criteria support.

Back to the top