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 7529917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:46:07+00:00 2026-05-30T04:46:07+00:00

W was trying to fetch join over three levels: JOIN FETCH entity1.collection1.collection2 // two

  • 0

W was trying to fetch join over three levels:

JOIN FETCH entity1.collection1.collection2  // two OneToMany relations

but got:

org.hibernate.HibernateException: Errors in named queries: [...]

Is it because it was too deep, or because a collection of collections cannot be fetched this way? My max fetch depth is 3, if this is relevant.

I can, at the same time, do a triple JOIN FETCH starting from the other side:

JOIN FETCH entity3.entity2.entity1  // two ManyToOne relations

Somehow I cannot find anything in JPA specification, or in Hibernate docs, that would limit the depth of this clause.

  • 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-30T04:46:08+00:00Added an answer on May 30, 2026 at 4:46 am

    collection1 is of type Collection. And a Collection doesn’t have a collection2 field. That’s how I reason about those kind of queries.

    You must the create an explicit join over the collection:

    select e from Entity1 e
    left join fetch e.collection1 as c1
    left join fetch c1.collection2 as c2
    

    Note that this will produce a cartesian product, and thus petentially returns a huge number of rows. Also note that it will only be possible if one of the two collections at least is a set. If they’re both bags, Hibernate will throw an exception when executing the query.

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

Sidebar

Related Questions

I'm trying to fetch Wikipedia pages using LWP::Simple , but they're not coming back.
I'm trying to perform a select query over two tables, one containing, for example,
I am trying to join 2 tables and trying to fetch the records, which
I am trying to join two tables. One being the sys.databases table and the
I am trying to understand the difference between LEFT JOIN and LEFT JOIN FETCH
I'm trying to fetch an annotation with an one to many relation but as
I am trying to join two EJB's using EJBQL (with an underlying MySQL data
I'm trying to use a Left join query to get the last three results.
I am trying to join three tables together without any success so far. I
I'm trying to fetch some HTML from various blogs and have noticed that different

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.