This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 303767 - Join fetch clause placed after Join clause in JPQL FROM is ignored
Summary: Join fetch clause placed after Join clause in JPQL FROM is ignored
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-02-24 10:16 EST by Gordon Yorke CLA
Modified: 2022-06-09 10:21 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gordon Yorke CLA 2010-02-24 10:16:22 EST
The following query will not result in an exception but will not join fetch any of the requested fields.

"select e from Employee e join e.managedEmployees m join fetch e.managedEmployees where m.address.city = 'Ottawa' "

This failure would be very difficult for a user to detect.
Comment 1 Tom Ware CLA 2010-03-02 11:32:24 EST
Setting target and priority.  See the following page for a description of the meanings of these values:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 2 James Sutherland CLA 2010-04-26 13:17:21 EDT
I believe the issue is a comma is missing, all joins must use a comma, otherwise there are assumed to be nested joins,

The JPQL should be,

select e from Employee e join e.managedEmployees m, join fetch
e.managedEmployees where m.address.city = 'Ottawa' 

Without the comma it is a nested join like,

select e from Employee e join fetch e.managedEmployees, join e.managedEmployees m join fetch
m.address where m.address.city = 'Ottawa' 

Otherwise you are join fetching the m, managedEmployees, not the e.  Not sure why this is not triggering an error though, we probably end up adding the e.managedEmployees expression to the joined attributes of m.

We should be raising an error when ever the wrong alias is used in a join, my guess this is not just join fetches, but any joins, 

i.e.
select e from Employee e join e.managedEmployees m join 
e.managedEmployees where m.address.city = 'Ottawa' 

or,

Select e from Employee e join m.address, Employee m where e.manager = m

You should get an error like "Wrong alias used in join"
Comment 3 Gordon Yorke CLA 2010-04-26 13:43:56 EDT
In the BNF the ',' us used to separate identification_variable_declarations not joins.  Each identification_variable_declaration may include any number of joins some of which would be nested and some that would not be but there is no ',' within the 'join' syntax.  A non nested join would be written as.

FROM Employee e JOIN e.address a JOIN e.manager , Project p JOIN p.teamLeader t
Comment 4 James Sutherland CLA 2012-02-06 11:21:46 EST
This works with Hermes, seems to be a bug in our ANTLR parser.
Comment 5 James Sutherland CLA 2012-04-11 10:44:37 EDT
Fixed in 2.4
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:21:01 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink