MyBatis使用Collection标签嵌套查询集合
一、嵌套结果集方式
使用collection标签定义关联的集合中属性封装的规则
查询报销信息时要把对应的车牌号等信息也查出来
<resultMap id="bxDetail" type="cn.model.cash.CashRecordDetail">
<id column="id" property="serialNo" jdbcType="INTEGER" />
<result column="bxSerialNo" property="bxSerialNo" jdbcType="VARCHAR" />
<result column="status_desc" property="status" jdbcType="VARCHAR" />
<result column="gmt_modified" property="time" jdbcType="VARCHAR" />
<collection property="dataList" ofType="cn.model.cash.BxDetail" javaType="java.util.ArrayList">
<!-- 定义几何中元素的封装规则 -->
<!-- 注:collection中要加入唯一标识列,否则collection嵌套的列的数据都相同的话将会自动合并 -->
<id