解决办法:取别名 关系: 商品(一)–>销售产品(多)–>采购产品(多) 写法一: 别名+columnPrefix xml:
<resultMap>
<result property="id" column="id" />
<result property="item_price_money" column="item_price_money" />
<collection property="ofOrderSellProductList" ofType="com.order.pojo.OfOrderSellProduct">
<id property="id" column="c_id" />
<result property="sell_sku" column="c_sell_sku" />
<result property="quantity_ordered" column="c_quantity_ordered" />
<result property="item_price_money" column="c_item_price_money" />
<collection property="ofOrderWhProductList" ofType="com.order.pojo.OfOrderWhProduct" resultMap="OfOrderWhProductResult" columnPrefix="wh_" />
</collection>
</resultMap>
sql:
select a.*,
c.id c_id,c.sell_sku c_sell_sku,c.quantity_ordered c_quantity_ordered,c.item_price_money c_item_price_money,
d.id wh_id,d.warehouse_sku wh_warehouse_sku ,d.warehouse_sku_num wh_warehouse_sku_num
from of_order a
left join of_order_sell_product c on c.of_order_no = a.of_order_no
left join of_order_wh_product d on c.id = d.order_sell_product_id and d.of_order_no = c.of_order_no
写法二: columnPrefix+columnPrefix
xml:
<resultMap>
<result property="id" column="id"/>
<result property="item_price_money" column="item_price_money"/>
<collection property="ofOrderSellProductList" ofType="com.order.pojo.OfOrderSellProduct" columnPrefix="c_" >
<id property="id" column="id"/>
<result property="sell_sku" column="sell_sku"/>
<result property="quantity_ordered" column="quantity_ordered"/>
<result property="item_price_money" column="item_price_money"/>
<collection property="ofOrderWhProductList" ofType="com.order.pojo.OfOrderWhProduct" resultMap="OfOrderWhProductResult1" columnPrefix="wh_" />
</collection>
</resultMap>
sql:
select a.*,
c.id c_id,c.sell_sku c_sell_sku,c.quantity_ordered c_quantity_ordered,c.item_price_money c_item_price_money,
d.id c_wh_id,d.warehouse_sku c_wh_warehouse_sku ,d.warehouse_sku_num c_wh_warehouse_sku_num
from of_order a
left join of_order_sell_product c on c.of_order_no = a.of_order_no
left join of_order_wh_product d on c.id = d.order_sell_product_id and d.of_order_no = c.of_order_no
|