ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Utkarsh Ahuja" <ahuja.utka...@gmail.com>
Subject Problem creating nested HashMaps using <result property="" column="" select=""/>
Date Tue, 27 Mar 2007 19:34:06 GMT
Hi,
I am trying to create nested HashMaps something like

ParentHashMap {
     ...... some key value pairs
     ......
     childHashMap....some key value pairs
}

I am doing the following:

    <resultMap id="parentResultMap" class="java.util.HashMap">
        <result column="parent_column_1" property="parentColumn1" />
        <result column="parent_column_1" property="parentColumn2" />
        <result column="parent_column_1" property="parentColumn3" />
        <!-- customizations -->
        <result column="parent_column_1" property="children"
resultMap="childResultMap" select="loadChildren"/>
    </resultMap>

    <select id="loadParent" parameterClass="java.util.HashMap"
resultMap="parentResultMap">
        select
            parent_column_1,
            parent_column_2,
            parent_column_3
        from parent
    </select>

    <resultMap id="childResultMap" class="java.util.HashMap">
        <result column="child_column_1" property="childColumn1" />
        <result column="child_column_2" property="childColumn2" />
        <result column="child_column_3" property="childColumn3" />
        <result column="parent_column_1" property="parentColumn1" />
    </resultMap>

    <select id="loadChildren" resultMap="childResultMap">
        select
           child_column_1,
           child_column_2,
           child_column_3,
           parent_column_1
        from child
        where parent_column_1 = #parentColumn1:VARCHAR#
    </select>

Can iBatis instantiate and create a HashMap within another HashMap and use
the property element as the key for it ?
<result column="parent_column_1" property="children"
resultMap="childResultMap" select="loadChildren"/>

Thanks
Utkarsh

Mime
View raw message