mybatis采坑
collection中的id需要取别名与之对应,否则出错
<resultMap id="supplier" type="com.ch.cooker.tob.facade.pojo.dbo.SupplierOrgDbo"> <id column="id" property="id"/> <result column="name" property="name"/> <result column="address" property="address"/> <result column="code" property="code"/> <result column="busi_name" property="busiName"/> <result column="handphone" property="handphone"/> <result column="org_a_id" property="salerId"/> <result column="licence" property="licence"/> <result column="permission" property="permission"/> <result column="status" property="status"/> <result column="date_start" property="contractDateStart"/> <result column="date_end" property="contractDateEnd"/> <collection property="goodsGroupVos" ofType="com.ch.cooker.tob.facade.pojo.dbo.GoodsGroupDbo" javaType="ArrayList"> <id column="gid" property="id"/> <result column="group_name" property="groupName"/> </collection> </resultMap>
<select id="getAllSupplier" resultMap="supplier"> SELECT soe.id,soe.name,soe.address,soe.code,soe.busi_name,soe.handphone,soe.`enable`, soc.date_start,soc.date_end,soc.status,bs.licence,bs.permission,bgg.group_name,bgg.id gid FROM sys_org so LEFT JOIN sys_org_entity soe ON so.org_entity_id = soe.id LEFT JOIN sys_org_relation sor ON sor.org_b_id = so.id LEFT JOIN sys_org_contract soc ON soc.relation_id = sor.id LEFT JOIN busi_suppliers bs ON soe.id = bs.org_entity_id LEFT JOIN busi_goods_group bgg ON bgg.org_id = so.id <where> so.type=4 <if test="supplier.orgId != null"> AND so.id = #{supplier.orgId} </if> <if test="supplier.status != null"> AND soe.enable = #{supplier.status} </if> <if test="supplier.name != null and supplier.name != ''"> AND soe.name LIKE concat(concat('%',#{supplier.name}),'%') </if> <if test="supplier.salerId != null"> AND sor.org_a_id = #{supplier.salerId} </if> <if test="current!=null"> limit #{current},#{size} </if> </where> </select>