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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:55:42+00:00 2026-06-01T18:55:42+00:00

I am trying to get some JPA stuff to work. I have a table

  • 0

I am trying to get some JPA stuff to work. I have a table that has foreign keys to another tables. When I generate the JPA entities I get one to many anotations over those variables… what else would I need to do get all the tables back in the result set? if I indeed call it. Here is an example of what I am trying to do.

@OneToMany(mappedBy="resourceId")
private List<DistributionLink> distributionLinkCollection;

@OneToMany annotation is sitting pretty…

I am thinking to get all values back I would need to just call the named query that calls for this table right?

qLaunchArr = (QuickLaunch[])emf.createNamedQuery("QuickLaunch.getQuickLaunch").getResultList().toArray();

Am I way off base to think that I will also get an array of DistributionLinks with all result sets?
Now I know this has something to do with Eager Loading vs Lazy loading. Exactly what, I am not sure. I know lazy loading only loads @oneToMany attributes explicitly called (I think)? How can I get back all those collections I will need. Will I need to loop through the result set and also call a named query to get all result sets using a named query?

Thanks.

  • 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-06-01T18:55:43+00:00Added an answer on June 1, 2026 at 6:55 pm

    When you choose to lazy load something depending on whether you’re still in the transaction context, when you fetch your child collection with a getter, JPA should automatically fetch it for you. So if the data leaves the session bean that has the entity manager that fetched the parent object, you will not be able to automatically instantiate the lazy loaded collection.

    If you choose to use an EAGER fetch strategy, each instance of that collection will be pre-instantiated and will be available anywhere.

    A good compromise that lets you avoid constraining your design decision (but still allows you to take advantage of lazy loading to avoid loading stuff you don’t need on every fetch of those records) to only dealing with these collections in the bean that fetches the parent entities would be to when you know in advance that you will need that collection, stick in your query:

    JOIN FETCH distributionLinks
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get some code working that a previous developer has written. Yep,
I'm trying to get some data stored locally using IndexedDB. Below I'm I have
I'm trying to get some code that will perform a perspective transformation (in this
Trying to get some initial bearings on useful processes that a basic working knowledge
we're trying to get some statistics over our large log tables on MySQL. Some
I'm trying to get some code to display based on a condition. I have
Trying to get some movies and their genres but leave out any records that
Basically I am trying to get some jQuery code to work with elements I
I am trying to build a few simple tables with JPA, but I have
Im trying to get some checkbox with a specific name document.getElementsByName(test); Unfortunatley i cant

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.