<resultMap type="com.dc.basisfiles.entity.extend.BasCommodityExtend" id="AfterBasCommodityMap"> <id property="commodityId" column="commodity_id" jdbcType="INTEGER"/> <result property="commodityCode" column="commodity_code" jdbcType="VARCHAR"/> --ofType指的是集合的实体属性名称。 <collection property="priceSubSheetEntityList" ofType="PriceSubSheetEntity"> <id property="id" column="price_id"/> <result property="commodityCode" column="price_commodity_code"/> </collection> </resultMap>
一对多的情况下,查询多条出来,配置了上面的map,mybatis会帮你自动合并,合并逻辑是根据实体类的主键来合并,实体里面的集合也是根据集合的主键来合并。