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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:50:37+00:00 2026-05-23T12:50:37+00:00

Suppose I have the following class: public class Foo { public Bar bar; }

  • 0

Suppose I have the following class:

public class Foo {
    public Bar bar;
}

One giant iBATIS query loads many instances of Foo and populates all of the bar fields from a database. I would like to split up the giant query into two:

  • One query to load many Foo instances, leaving the bar fields null.
  • Another query to load all of the bar fields for some associated Foo instances.

The idea is that the first query would be executed initially, then the second would be executed only if needed later on.

The trick is the association. I can batch load bar fields, but what’s the best way to inject that data back into the associated Foos? Is there any way around having one query executed per lazily-loaded instance field? This seems like it would counteract the performance benefits of iBATIS.

  • 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-23T12:50:37+00:00Added an answer on May 23, 2026 at 12:50 pm

    Although it is tempting to load object graphs from the database, we usually try to avoid that because it means one query per member, and when fetching large sets, can result in many, many queries on the database and long response times.

    Therefore we usually model it in such a way that the member is seperated. Let’s say you have a Shop with Users. Instead of modelling the Users as a list in your shop, you have a DAO call which reads “List getUsersForShop(shop)”.

    Some of our pages go even furter. For paginated web pages, there’s no use to get all objects from the database, since they’re not displayed at the same time. So we split it even further:

    List getUserIdsForShop(shop)

    and then for each row on the page, we do “User getUserForId(long id)”.

    This will result in minimal dataflow between the server, the database and the client, and will reduce the number of calls per page. If your search result is 10.000 users, but you only display 10 per page, you’ve just saved the fetching of 99990 users, and holding them in memory.

    Don’t use this as a hammer for all your nails. It’s just an option to consider for large object graphs.

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

Sidebar

Related Questions

Suppose I have: class Foo { ... }; class Bar : public Foo {
Suppose I have the following class: public class Foo { private List<Integer> list =
Suppose I have classes Foo and Bar as follow: public class Foo { public
Suppose I have the following class: public class TestBase { public bool runMethod1 {
Suppose I have the following class hierarchy: class A { int foo; virtual ~A()
Suppose I have two classes defined the following way: public class A { public
Suppose I have the following: class dataClass { public: int someData; float moreData; void
Suppose I have the following class. public class gen<T> { public gen(){ } Class<T>
Suppose I have the following hierarchy: class A { public: A() private: int aa;
Suppose you have the following object hierarchy: class Vehicle { public: virtual ~Vehicle() {}

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.