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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:25:54+00:00 2026-06-15T15:25:54+00:00

Entity A has two unidirectional & lazy one-to-one relationships to B (i.e. there’s no

  • 0

Entity A has two unidirectional & lazy one-to-one relationships to B (i.e. there’s no inverse relationship).

@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = false)
@JoinColumn(name = "first_b_id")
private B firstB;

@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = false)
@JoinColumn(name = "second_b_id")
private B secondB;

Lazy-loading works fine. BUT if I invoke

myA.getSecondB()

the SQL log shows that Hibernate issues something like

select * from B where id in (value1, value2)

Hence, the relationships are treated lazily but they’re all loaded at once.
What are the explanations and work-arounds for this?

Oh, why is that so relevant you may ask… Well, the B entities are LOBs. One is the 5+MB original, the other is a 200KB “preview”. Of course I only want to load the original if absolutely necessary.

  • 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-15T15:25:55+00:00Added an answer on June 15, 2026 at 3:25 pm

    The explanation is probably that you enabled batch fetching for the class B (or for every entity using the hibernate.default_batch_fetch_size configuration property).

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

Sidebar

Related Questions

I've an associated entity with <many-to-one> and that entity has two <many-to-one> that I
My Core Data model contains an entity, Shape, that has two self-referential relationships, which
I have only one entity, which has two attributes: an NSString attribute and a
I have a data model which has two entities in a relationship of one
I need to have an entity that has two separate candidate keys where one
There's an entity A . In addition, there's an entity B which has two
My database has two tables, Reads and Alarms . There is a one to
Lets say thay I have an entity with name A.It has two columns named
I have two entities // All details has been removed @Entity @Table(name = "A_TABLE_NAME")
I'm using Hibernate with Xml mappings. I have an entity that has two fields

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.