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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:22:49+00:00 2026-05-28T07:22:49+00:00

I have Persistent class, referring to many collections with LAZY fetch type, like @Entity

  • 0

I have Persistent class, referring to many collections with LAZY fetch type, like

@Entity
@Table(name = "TABLE")
public class Table implements Serializable {
    ....


    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "LIST1", nullable = true)
    private ArrayList list1;

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "LIST2", nullable = true)
    private ArrayList list2;

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "LIST1", nullable = true)
    private ArrayList list1;

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "LIST2", nullable = true)
    private ArrayList list2;

....

}

I have instantiated some objects of type TABLE through Hibernate, added it to a list of Tables, and now want to fetch one of this collections (say list2) for all objects in this list.

for(Table table:tables){
     result=table.list2;
     ....
}

But this way Hibernate will generate sequence of separate SQL queries. Can hibernate fetch list2 for all the objects in collection in one query? (It is important not to create new Table class instances, but modify objects, that are already exists)

  • 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-28T07:22:50+00:00Added an answer on May 28, 2026 at 7:22 am

    From the reference manual:

    A “fetch” join allows associations or collections of values to be
    initialized along with their parent objects using a single select.
    This is particularly useful in the case of a collection. It
    effectively overrides the outer join and lazy declarations of the
    mapping file for associations and collections.

    select t from Table t
    left join fetch t.list2
    where ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using app engine datastore so I have entity like this. @PersistenceCapable public class
I have a persistent class Author with two fields: int id , String name
I am using the SQLite database and have the following persistent class (simplified): public
I have a class: @PersistenceCapable public class X{ @Persistent @Order(extensions = @Extension(vendorName = datanucleus,
I have the following data model class defined: @PersistenceCapable public class TestSerializableModelObj { @Persistent(serialized=true,
I have the following entity class (in Groovy): import javax.persistence.Entity import javax.persistence.Id import javax.persistence.GeneratedValue
Suppose I have some per-class data: (AandB.h) class A { public: static Persister* getPersister();
I have three classes (House, Room, Address) which are persistent (Mapped with JPA/Hibernate) @Entity
I have a web app, I'd like the user to supply their real name,
I have many html forms referring to many persistence classes. All the html forms

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.