标签:
<resultMap id="cpBookCategoryResultMap"
type="busines.administer.cp.model.CPBookCategory">
<result column="id" property="id" />
<result column="name" property="name" />
<result column="pid" property="pid" />
<result column="is_parent" property="isParent" />
<result column="ctime" property="ctime" />
<result column="utime" property="utime" />
<association property="childList" column="id" select="getCategoryChildList"/>
</resultMap>
<resultMap id="cpBookCategoryResultMap_2"
type="java.util.HashMap">
<result column="id" property="id"/>
<result column="name" property="name" />
<result column="pid" property="pid" />
<result column="is_parent" property="isParent" javaType="boolean"/>
<association property="children" column="id" select="getCategoryChildList"/>
</resultMap>
<select id="getCategoryChildList" resultMap="cpBookCategoryResultMap_2">
<![CDATA[
SELECT id, name, is_parent,pid FROM cp.tbl_cp_category where pid=#{value};
]]>
</select>
解释:1)busines.administer.cp.model.CPBookCategory这个类中有childList这样一个属性。
2)这个属性childList是一个集合,显然不会是对应数据库表中的某一字段,它来源于另一张表(根据CPBookCategory的id的值作参数)的查询结果集
3)将getCategoryChildList查询的结果集,填充到busines.administer.cp.model.CPBookCategory的childList属性中,返回
参考:
http://www.cnblogs.com/xdp-gacl/p/4264440.html (写得最好)
http://blog.csdn.net/isea533/article/details/20868189
http://cczakai.iteye.com/blog/1276722
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/u010913106/article/details/48104491