Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 991159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:03:49+00:00 2026-05-16T06:03:49+00:00

I would like to be able to swap my JPA implementation between EclipseLink &

  • 0

I would like to be able to swap my JPA implementation between EclipseLink & Hibernate with a simple property change. I can do this ok but what is causing me problems is the named query validation. Using EclipseLink I have to write fetch joins like so:

SELECT id 
FROM IndexDefinition id 
JOIN FETCH id.index 
JOIN id.index i
JOIN FETCH i.indexVersions

But when validating this query using Hibernate I get the following exception:

org.hibernate.QueryException: query specified join fetching, but the owner of the fetched association was not present in the select list 

So I can change the query to be HQL friendly like so:

SELECT id 
FROM IndexDefinition id 
JOIN FETCH id.index i
JOIN FETCH i.indexVersions

But this then causes the following exception in EclipseLink:

Exception Description Syntax error parsing the query [IndexDefinition.getForIndex] SELECT id FROM IndexDefinition id JOIN FETCH id.index i, syntax error at [id].
Internal Exception MismatchedTokenException(78!=-1)

I know I can use query hints at my DAO level to perform a fetch join but is there a way of pleasing both JPA implementations with a specific fetch join syntax?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:03:49+00:00Added an answer on May 16, 2026 at 6:03 am

    Well, it seems that nested joins are not supported by the JPA 1.0. From the JPA 1.0 specification:

    4.4.5.3 Fetch Joins

    A FETCH JOIN enables the fetching of
    an association as a side effect of the
    execution of a query. A FETCH JOIN is
    specified over an entity and its
    related entities.

    The syntax for a fetch join is

    fetch_join ::= [ LEFT [OUTER] | INNER ] JOIN FETCH join_association_path_expression
    

    The association referenced by the
    right side of the FETCH JOIN clause
    must be an association that belongs to
    an entity that is returned as a result
    of the query. It is not permitted to
    specify an identification variable for
    the entities referenced by the right
    side of the FETCH JOIN clause, and
    hence references to the implicitly
    fetched entities cannot appear
    elsewhere in the query
    .

    The following query returns a set of
    departments. As a side effect, the
    associated employees for those
    departments are also retrieved, even
    though they are not part of the
    explicit query result. The persistent
    fields or properties of the employees
    that are eagerly fetched are fully
    initialized. The initialization of the
    relationship properties of the
    employees that are retrieved is
    determined by the metadata for the
    Employee entity class.

    SELECT d
    FROM Department d LEFT JOIN FETCH d.employees
    WHERE d.deptno = 1
    

    A fetch join has the same join
    semantics as the corresponding inner
    or outer join, except that the related
    objects specified on the right-hand
    side of the join operation are not
    returned in the query result or
    otherwise referenced in the query.
    Hence, for example, if department 1
    has five employees, the above query
    returns five references to the
    department 1 entity.

    So, while nested joins might be supported by some JPA providers, the behavior is not standardized.

    References

    • JPA 1.0 Specification
      • Section 4.4.5.3 “Fetch Joins”
    • JPA Wikibook
      • Nested Joins
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.