前提:整合配置请看springboot整合mybatis篇
1.在mapper接口中编写方法(参数为list集合)
/**
* 批处理存储数据进入表
*/
Integer batchInsertTOrderItems(@Param("tOrderItemlist") List<TOrderItem> tOrderItemlist);
2.编写mapper.xml配置文件(注解也可以我这里就不多解释了)
<mapper namespace="com.quanzhan.mapper.TOrderItemMapper">
<insert id="batchInsertTOrderItems" parameterType="java.util.List">
insert into t_order_item (book_name,price,img_path,item_count,item_amount,order_id)
values
<foreach collection="tOrderItemlist" item="item" index="index" separator=",">
(#{item.bookName},#{item.price},#{item.imgPath},#{item.itemCount},#{item.itemAmount},#{item.orderId})
</foreach>
</insert>
</mapper>
3.此时就可以进行批处理了!赶快试试吧