MyBatis中对List<Object> 对象List的批处理插入操作:
首先需要定义对象的<resultMap type="com.travelsky.domain.Order" id="orderResult">
然后:
<select id="insertOrderDish" parameterType="java.util.List">
insert into
ordersdish(id,ordersId,dishId)
values
<foreach collection="list" item="item" index="index"
separator=",">
(#{item.id,jdbcType=VARCHAR},#{item.orderId,jdbcType=BIGINT},#{item.dishId,jdbcType=INTEGER})
</foreach>
</select>
出处:http://www.linuxidc.com/Linux/2014-02/96916.htm