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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:35:38+00:00 2026-06-05T19:35:38+00:00

According to Hibernate documentation : After observing that arrays cannot be lazy , you

  • 0

According to Hibernate documentation :

After observing that arrays cannot be lazy, you can conclude that lists, maps and idbags are the most performant (non-inverse) collection types

So my question is dead simple : why arrays cannot be lazy-loaded in a one-to-many assocation ?

  • 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-05T19:35:39+00:00Added an answer on June 5, 2026 at 7:35 pm

    Lazy load works by the fact that Hibernate uses structures that can be proxied to know when you try to access the data for the first time. When you do this, these structures will tell hibernate that they now need to load the information and Hibernate will then do this on-the-fly, without you knowing what’s happening.

    Arrays can’t be lazy loaded because Hibernate wouldn’t have a way to know you are trying to access them for the first time, since you can’t proxy the “[]” operator ( the aaload bytecode ), Hibernate would never know when you first tried to access it so it would not be able to load it on the fly.

    When using collections, you always have to access them through their methods, so Hibernate can be 100% sure when you’re trying to access them for the very first time and then load them.

    So, the real reason is that there is no way to hook your code to the array access operator. The same happens on lazy loading for fields, Hibernate can’t lazy load a non-collection property with field only access as it wouldn’t know when you tried to access the field, they always need to have get/set method access.

    As an example of how this is done, you can check the PersistentList collection on Hibernate, on it’s indexOf method (and many others) the read method is called:

    public int indexOf(Object value) {
        read();
        return list.indexOf(value);
    }
    

    And in the end the read method just initializes the collection if it hasn’t been lazy loaded yet.

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

Sidebar

Related Questions

Hibernate can auto-generate schemas from properly annotated POJO classes. And I also know that
According to this section of the Hibernate documentation I should be able to query
I am new in hibernate,after read the hibernate api and tutorial,it seems that the
According to connects documentation the session should expire when the browser is closed: By
According to this article I know, that DateTimePicker control does not reflect CurrentUICulture So,
According to C++11 9.1/7 (draft n3376) , a standard-layout class is a class that:
According to Boost documentation boost::mutex and boost::timed_mutex are supposed to be different. The first
According to the Google App Engine documentation, writing to one entity group is limited
According to Xeround's Release Notes they don't support save points and I can't figure
I have the following Hibernate code that is returning an error. The results of

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.