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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:47:26+00:00 2026-05-21T11:47:26+00:00

Given a ResultMap for an iBatis select query, it seems obligatory that all columns

  • 0

Given a ResultMap for an iBatis select query, it seems obligatory that all columns (that are mapped to properties in the ResultMap) are actually part of the SQL query.

But that’s a bit annoying if one wants to reuse ResultMaps, particularly when having ‘resultmaps within resultmaps’.

Example:

    <resultMap id="myResultMap"
      <result property="myPropName" column="myColumnName"/>
      <result property="someCollection" resultMap="otherResultMap"/>
    </resultMap>

    <resultMap id="otherResultMap" groupBy="..."
      <result property="otherPropName" column="otherColumnName"/>
    </resultMap>

Of course, these two result maps are defined because there is a case with a query that uses a join to load the container objects holding myPropName and someCollection holding a collection of inner objects.

But if I want to reuse the same result map definition for another select query that only needs to load the container objects (with myPropName), but doesn’t need to load the inner objects (into someCollection), then there will be an error message:

The column name ‘otherColumnName’ was
not found in this ResultSet

Is there no possibility that allows to initialize the someCollection with null or an empty collection if the respective properties (in this case otherPropName) are not present in the SQL query?

Is it really necessary to create another result map altogether for that scencario?

Using the iBatis (not myBatis yet) version 2.3.4…

  • 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-21T11:47:27+00:00Added an answer on May 21, 2026 at 11:47 am

    The “problem” is in all the TypeHandler implementations. These objects have to extract the column value from ResultSet mapping it to the corresponding java type. For instance, in StringTypeHandler class there’s a method like this:

    public Object getResult(ResultSet rs, String columnName) throws SQLException {
        Object s = rs.getString(columnName);
        if (rs.wasNull()) {
            return null;
        } else {
            return s;
        }
    }
    

    If the column is not present in the ResultSet, the line rs.getString(columnName) throws a SQLException. The only way to avoid this error is writing your own TypeHandler which returns null instead of throwing the exception.
    Anyhow, I suggest you to use two resultmaps.

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

Sidebar

Related Questions

Given a simple statement, such as: <statement id=SelectProducts resultMap=???> SELECT * FROM Products </statement>
Given a select with multiple option's in jQuery. $select = $(<select></select>); $select.append(<option>Jason</option>) //Key =
Given a table that has a column of string timestamps (yyyyMMddHHmmssSSS format), I want
Given a tabbed delimited text file with two columns name and date: Sam 20100101
Given that acronym is removed in HTML 5, how does one get standards support
Given a tree, how to find the centre node in the tree so that
Given a specific DateTime value, how do I display relative time, like: 2 hours
Given a Python object of any kind, is there an easy way to get
Given a DateTime representing a person's birthday, how do I calculate their age in
Given an absolute or relative path (in a Unix-like system), I would like to

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.