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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:56:17+00:00 2026-05-10T16:56:17+00:00

Relating to my earlier question , I want to ensure all the child objects

  • 0

Relating to my earlier question, I want to ensure all the child objects are loaded as I have a multiple threads that may need to access the data (and thus avoid lazy loading exceptions). I understand the way to do this is to use the ‘fetch’ keyword in the query (EJB QL). Like this:

select distinct o from Order o left join fetch o.orderLines 

Assuming a model with an Order class which has a set of OrderLines in it.

My question is that the ‘distinct’ keyword seems to be needed as otherwise I seem to get back an Order for each OrderLine. Am I doing the right thing?

Perhaps more importantly, is there a way to pull in all child objects, no matter how deep? We have around 10-15 classes and for the server we will need everything loaded… I was avoiding using FetchType.EAGER as that meant its always eager and in particular the web front end loads everything – but perhaps that is the way to go – is that what you do? I seem to remember us trying this before and then getting really slow webpages – but perhaps that means we should be using a second-level cache?

  • 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. 2026-05-10T16:56:18+00:00Added an answer on May 10, 2026 at 4:56 pm

    Changing the annotation is a bad idea IMO. As it can’t be changed to lazy at runtime. Better to make everything lazy, and fetch as needed.

    I’m not sure I understand your problem without mappings. Left join fetch should be all you need for the use case you describe. Of course you’ll get back an order for every orderline if orderline has an order as its parent.

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

Sidebar

Related Questions

After reading multiple threads relating to this I can only conclude that I must
two relating question: I have a table that is in use in a production
Relating to my last question here: Rails: Finding all associated objects to a parent
I have a question relating to modifying the individual items in an ObservableCollection that
I have this question relating to Lucene. I have a form and I get
I have a question relating to alignment in C/C++. In Determining the alignment of
(Relating to an earlier question of mine: Playing a Video (MSDN Tutorial) ) I
I have a question relating to properties for a specific instance of a CI
This question is relating to a specific functionality that a client has requested for
I have a HashMap relating Keys to Strings, and I need to compare some

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.