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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:27:55+00:00 2026-05-15T06:27:55+00:00

I have a database that is similar to the following: create table Store(storeId) create

  • 0

I have a database that is similar to the following:

create table Store(storeId)
create table Staff(storeId_fk, staff_id, staffName)
create table Item(storeId_fk, itme_id, itemName)

The Store table is large.

And I have create the following java bean

public class Store
{
    List<Staff> myStaff
    List<Item> myItem

   ....
}

public class Staff
{
    ...
}

public class Item
{
   ...
}

My question is how can I use iBatis’s result map to EFFICIENTLY map from the tables to the java object?

I tried:

<resultMap id="storemap" class="my.example.Store">
  <result property="myStaff" resultMap="staffMap"/>
  <result property="myItem" result="itemMap"/>
</resultMap>

(other maps omitted)

But it’s way too slow since the Store table is VERY VERY large.

I tried to follow the example in Clinton’s developer guide for the N+1 solution, but I cannot warp my mind around how to use the “groupBy” for an object with 2 list…

Any help is appreciated!

  • 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-15T06:27:56+00:00Added an answer on May 15, 2026 at 6:27 am

    When you start wanting to load a graph of objects, you begin to understand why iBatis is not an ORM, just an object mapper. You are right that the recipe for loading a relation in a mapping (avoiding the N+1 problem) with iBatis’s groupBy feature is difficult to generalize for your scenario. I think it could be done, but I wouldn’t bother.

    Usually one implements either some lazy loading here, or load explicitly the related objects.
    Anyway, I’m not sure what is your goal. You say “the Store table is VERY VERY large”.
    Now, do you intend to load many Store objects? Do you really need the related objects?
    Ask yourself (when designing with iBatis) what would be the ideal SQL to be executed.

    And don’t forget that there can be different scenarios for dealing with your objects, and not necesarily all of them must use the same mappings.

    For example, frequently one has two types of use cases related to the Store objects: in the first type, one needs to load the full “object graph” but only for one (or a few) root object (one Store); in the other type one must load many “Stores” (with related data) but just for some listing or report. Then, one can do different things you each kind of scenario: in the first, one loads the full object with the related objects (perhaps with lazy loading, without much worrying about N+1 problem); in the second, one does not really load full Store object graph but just some dummy StoreWithExtraData DTO object (perhaps even a plain HashMap!) which correspond to a row of the listing – and one can accomplish this, in iBatis, with an ad-hoc SQL query and mapping.

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

Sidebar

Related Questions

I have a table schema similar to the following (simplified): CREATE TABLE Transactions (
I have a database that contains a table that looks a bit like this:
My database contains the following strings along with others that are similar Old Type:
I have a database that contains a date and we are using the MaskedEditExtender
I have a database that I would like class files generated from, and also
I have a database that many different client applications (a smattering of web services,
I have a database that i'm dealing with which is updated every few hours
I have a database that is stuck in single-user mode. I kill the process
We have a database that persist our metadata and data. Our metadata is produced
I have a database that hold's a user's optional profile. In the profile I

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.