oracle系列之-数据库使用mybatis批量插入

xiaoxiao2021-02-28  64

<insert id="insertSelective" useGeneratedKeys="true" parameterType="java.util.List"> <!-- WARNING - @mbggenerated This element is automatically generated by MyBatis Generator, do not modify. --> <selectKey keyProperty="id" order="BEFORE" resultType="java.math.BigDecimal"> select DISCOUNT_COUPON_PERSON_SEQ.NEXTVAL from DUAL </selectKey> insert into T_DISCOUNT_COUPON_PERSON ( ID, USER_ID, COUPON_ID, ORDER_SHOP_ID, COUPON_GET_WAY, COUPON_GET_CHANNEL, COUPON_GET_DATE, COUPON_USE_DATE, MONEY_BACK_APPLY_DATE, COUPON_USE_STATUS, CANCEL_LOCK_REASON, CREATE_TIME, MODIFY_TIME) select logsaccessseq.NEXTVAL,a.* from ( <foreach collection="list" item="item" index="index" separator="union all"> select #{item.userId,jdbcType=DECIMAL} as userId, #{item.couponId,jdbcType=VARCHAR} as couponId,#{item.orderShopId,jdbcType=VARCHAR} as orderShopId,#{item.couponGetWay,jdbcType=VARCHAR} as couponGetWay, #{item.couponGetChannel,jdbcType=VARCHAR} as couponGetChannel,#{item.couponGetDate,jdbcType=TIMESTAMP} as couponGetDate,#{item.couponUseDate,jdbcType=TIMESTAMP} as couponUseDate, #{item.moneyBackApplyDate,jdbcType=TIMESTAMP} as moneyBackApplyDate,#{item.couponUseStatus,jdbcType=VARCHAR} as couponUseStatus,#{item.cancelLockReason,jdbcType=VARCHAR} as cancelLockReason, #{item.createTime,jdbcType=TIMESTAMP} as createTime,#{item.modifyTime,jdbcType=TIMESTAMP} as modifyTime from dual </foreach> ) a </insert>

 

转载请注明原文地址: https://www.6miu.com/read-72873.html

最新回复(0)