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

  • SEARCH
  • Home
  • 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 4000058
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:44:04+00:00 2026-05-20T07:44:04+00:00

In the projects where Hibernate is my persistence provider, I can issue queries with

  • 0

In the projects where Hibernate is my persistence provider, I can issue queries with ‘join fetch’ expressions, and Hibernate will generate SQL that mirrors that: SQL containing join expressions using valid paths of comparison.

EclipseLink, however, issues SQL with ugly Cartesian plans, that hurt performance quite badly. While reading this article , it mentions that eagerly fetching might generate Cartesian plans, but it conveniently forgets that other providers (Hibernate) can optimize that.

So, is it possible to instruct EclipseLink to optimize these queries? I believe that few relationships can be optimized through the usage of the @FetchJoin annotation, but I’m hoping to find something that does not include spreading ORM-specific annotations on the domain model.

As an example, here’s a (dynamic) query that I’m issuing as JPQL:

String query = "select w from WorkOrder w " +
            "inner join fetch w.type " +
            "inner join fetch w.details " +
            "inner join fetch w.project " +
            "inner join fetch w.priority " +
            "inner join fetch w.networkElement ";

And here’s the EclipseLink output:

SELECT t1.ID, t1.CREATION, ... (the fetch fields here)
FROM swa_network_element t5, swa_priorities t4, swa_dispatch_project t3, swa_work_order_detail t2, swa_work_orders t1, swa_work_order_type t0
WHERE ((t1.alpha_id LIKE '%TSK%') AND (((((t0.ID = t1.TYPE_ID) AND (t2.worder_id = t1.ID)) AND (t3.id = t1.project_id)) AND (t4.ID = t1.priority_id)) AND (t5.ID = t1.ne_id))) ORDER BY t1.CREATION DESC

Best regards,
Rodrigo Hartmann

  • 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-20T07:44:05+00:00Added an answer on May 20, 2026 at 7:44 am

    Try using:

    @org.eclipse.persistence.annotations.JoinFetch(JoinFetchType.INNER)

    — or —

    @org.eclipse.persistence.annotations.JoinFetch(JoinFetchType.OUTER)

    Outer joins are recommended for nullable columns.

    I’ve found more information in this blog: http://vard-lokkur.blogspot.com/2010/09/jpa-demystified-episode-1-onetomany-and.html

    Regards,

    Victor Tortorello Neto

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

persistence.xml looks like this: <persistence-unit name=testPU transaction-type=RESOURCE_LOCAL> <provider>org.hibernate.ejb.HibernatePersistence</provider> <non-jta-data-source>jdbc/test</non-jta-data-source> <jar-file>../../lib/app-services-1.0.jar</jar-file> <exclude-unlisted-classes>false</exclude-unlisted-classes> </persistence-unit> It is
We have a few maven projects that inherit from eachother. Our persistence layer project's
I am setting up a project that uses hibernate, and I am writing the
I have a project that use both dependencies independently: BoneCP and Hibernate. But thanks
I have several java projects which use hibernate to persist to a DB. At
I am using Spring-3.0.5 and Hibernate-3 for a project that I am working on.
This is my current project structure: pom.xml /src /main /resources hibernate.cfg.xml /META-INF persistence.xml I
I'm working on an application that requires the use of both JPA/Hibernate and RMI.
I have big problem with basic of the Hibernate in all my projects. I
I am new to Hibernate, reading this book Java persistence with Hibernate and I

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.