ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shepherdz <zhaoxin...@ndtech.com.cn>
Subject Re: When returning mutiple objects and transforming "directly to xml
Date Tue, 06 Jun 2006 01:19:17 GMT

RowHandler will be OK in mapping results with no nested structure. But I'm
afraid that it cannot handle result with nested structure. Look the
following mapping I used for testing:

<sqlMap namespace="TEST">
  <resultMap id="Master" class="java.util.HashMap" groupBy="id">
    <result property="id" column="MasterID" />
    <result property="name" column="MasterName" />
    <result property="details" javaType="java.util.ArrayList"
resultMap="TEST.Detail" />
  </resultMap>
  <resultMap id="Detail" class="java.util.HashMap" groupBy="id">
    <result property="id" column="DetailID"/>
    <result property="name" column="DetailName"/>
    <result property="anothers" javaType="java.util.ArrayList"
resultMap="TEST.Another"/>
  </resultMap>	
  <resultMap id="Another" class="java.util.HashMap">
    <result property="id" column="AnotherID"/>
    <result property="name" column="AnotherName"/>
  </resultMap>
  <select id="showMaster" parameterClass="java.lang.String"
resultMap="TEST.Master">
    SELECT M.M_ID as MasterID, M.M_Name as MasterName,
    D.D_ID as DetailID, D.D_Name as DetailName,
    A.A_ID as AnotherID, A.A_Name as AnotherName
    FROM MasterTable M
    LEFT OUTER JOIN DetailTable D ON D.MasterTable = M.M_ID
    LEFT OUTER JOIN AnotherTable A ON A.DetailTable = D.D_ID
    WHERE M.M_ID = #value#
  </select>
</sqlMap>

How does RowHandler handle this?
--
View this message in context: http://www.nabble.com/When-returning-mutiple-objects-and-transforming-%22directly-to-xml-t1718587.html#a4725268
Sent from the iBATIS - User - Java forum at Nabble.com.


Mime
View raw message