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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:09:16+00:00 2026-06-01T10:09:16+00:00

How should I map multiple columns with List in IBATIS ? I have a

  • 0

How should I map multiple columns with List in IBATIS ?

I have a Bean, say :

public class AttendanceBean {
    private String user_id;
    private String user_name;
    private List daysArray;
    // setter/getter methods
}

Ibatis (select clause in sqlMap):

<select id="someName" parameter="param">
   select user_id,user_name,
        day_1,
        day_2,
        day_3,
         ...
         ...
        day_31
    from table1,table2 
    where table1.userid=table2.userid
<select>

My question is how I am going to Map AttendanceBean’s daysArray with columns day_1, day_2, … day_31 in ResultMap even though I can simply write JDBC code for this as follows:

List alluser = new ArrayList();
while (rs.next()) {
    AttendanceBean ab = new AttendanceBean();
    ab.setUser_id(rs.getString("USER_ID"));
    ab.setUser_name(rs.getString("USER_NAME"));
    List tempArray = new ArrayList(); 
    for (int i=1;i<=noOfDaysinMonth;i++) {
        tempArray.add(rs.getString("DAY_"+i));
    }
    ab.setDayArray(tempArray);
    alluser.add(ab);
}  
  • 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-01T10:09:17+00:00Added an answer on June 1, 2026 at 10:09 am

    Faraz I take the daysArray is the number of days a particular user attended? It would be helpful to add some details of your schema. The table that has the number of days also has the user Id as well? Assuming you have a similar case you can do the following (this example is based on iBatis version 2.3.4).

    <select id="retrieveAllUserAttendences" resultMap="exampleUserAttendences">
        SELECT 
        table1.user_id, 
        table1.user_name,
        table2.day
        FROM table1
        INNER JOIN table2 ON table2.user_id = table1.user_id
    </select>
    
    <resultMap id="exampleUserAttendences" class="AttendanceBean" groupBy="user_id">
        <result property="user_id" column="user_id" jdbcType="VARCHAR" javaType="java.lang.String"/>        
        <result property="user_name" column="user_name" jdbcType="VARCHAR" javaType="java.lang.String"/> 
        <result property="daysArray" resultMap="sqlMapNamespace.exampleDaysResultMap" />       
    </resultMap>
    
    <resultMap id="exampleDaysResultMap" class="java.lang.String">
        <result property="daysArray" column="day_column_name" jdbcType="VARCHAR" javaType="java.lang.String"/>
    </resultMap>   
    

    Again I must stress this is an example and depends on how you store your data/schema is, however hope this example helps.

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

Sidebar

Related Questions

I have multiple classes that I need to map into 1 class: This is
I have a table with four columns, say P_Key(int), Ref_Key(int), Key(String), Value(Integer). I want
Let's say I have a HashMap declared as follows: @GuardedBy(pendingRequests) private final Map<UInt32, PendingRequest>
I have a model where multiple classes have a list of value types: class
Can anyone please explain me the meaning of implementing Map class and how should
I need a key in the map, however, I found it should be multiple
I'm trying to have multiple values for profFName and profLName display on a map
Im making an map with different markers which should have different info windows. But
I have a map with multiple markers, which I populate via an array. Each
I have put multiple markers on my map by click event and now 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.