数组套数组的形式写法
1.dao层
List<Regulation> queryAllRegulations();
配置
<resultMap id="RegulationResultMap" type="com.elfsack.cs.dto.allot.Regulation"> <result column="shop_code" property="shopCode" /> <result column="shop_name" property="shopName" /> <result column="exclusive_warehouse_code" property="exclusiveWarehouseCode" /> <result column="exclusive_warehouse_name" property="exclusiveWarehouseName" /> <result column="activity_warehouse_code" property="activityWarehouseCode"/> <result column="activity_warehouse_name" property="activityWarehouseName"/> <result column="share_warehouse_code" property="shareWarehouseCode" /> <result column="share_warehouse_name" property="shareWarehouseName" /> <result column="status" property="status"/> <collection property="regulationDetailList" ofType="com.elfsack.cs.dto.allot.RegulationDetail"> <result column="id" property="id"/> <result column="type" property="type"/> <result column="parameter_code" property="parameterCode" /> <result column="parameter_name" property="parameterName" /> <result column="parameter_value" property="parameterValue" /> <result column="expression" property="expression"/> <result column="participation" property="participation" /> </collection> </resultMap>
sql:
<select id="queryAllRegulations" resultMap="RegulationResultMap"> SELECT r.shop_code, r.shop_name, r.exclusive_warehouse_code, r.exclusive_warehouse_name, r.activity_warehouse_code, r.activity_warehouse_name, r.share_warehouse_code, r.share_warehouse_name, r.status, rd.id, rd.type, rd.parameter_code, rd.parameter_name, rd.parameter_value, rd.expression, rd.participation FROM allot_regulation r, allot_regulation_detail rd WHERE r.id = rd.regulation_id ORDER BY rd.regulation_id, rd.type, rd.sort_num </select>
mybatis自动生成集合套集合的形式