oracle数据库使用mybatis批量插入

来源:互联网 发布:java web哪本书 编辑:程序博客网 时间:2024/06/16 12:48
<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 modifyTimefrom dual</foreach>) a  </insert>  

0 0