MyBatis中對List<Object> 對象List的批處理插入操作

來源:互聯網
上載者:User

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>

相關閱讀:MyBatis快速入門教程

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.