spring springmvc mybatis 整合批量操作,批量更新,批量插入

来源:互联网 发布:php class 变量 编辑:程序博客网 时间:2024/04/29 12:46

1.批量插入

 <insert id="insertMonthAmountRechargeList"  parameterType="java.util.List">        INSERT INTO CISHAN_SUBSIDY_ACCOUNT_RECHARGE_MONTH(BATCH_NO,ACCOUNT_ID,USER_ID,        NAME,IDNO,MOBILE,MONTH_AMOUNT,CISHAN_CHANNEL_ID,CISHAN_ORG_PROVINCE,CISHAN_ORG_CITY,        CISHAN_ORG_COUNTY,CREATE_TIME,UPDATE_TIME)        VALUES       <foreach collection="list" item="item" index="index" separator="," >        (#{item.batchNo,jdbcType=INTEGER},#{item.accountId,jdbcType=BIGINT},        #{item.userId,jdbcType=BIGINT},#{item.name,jdbcType=VARCHAR},#{item.idNo,jdbcType=INTEGER},#{item.mobile,jdbcType=VARCHAR},        #{item.monthAmount,jdbcType=DECIMAL},#{item.channelId,jdbcType=BIGINT},        #{item.provinceId,jdbcType=BIGINT},#{item.cityId,jdbcType=BIGINT},#{item.countyId,jdbcType=BIGINT},        #{item.createTime,jdbcType=TIMESTAMP},#{item.updateTime,jdbcType=TIMESTAMP})       </foreach>  </insert>



2.批量更新

<update id="updateRechargeMonthStatusList"  parameterType="java.util.List">   <foreach collection="list" item="item" index="index" open="" close="" separator=";">UPDATE CISHAN_SUBSIDY_ACCOUNT_RECHARGE_MONTH <set>  STATUS = #{item.status,jdbcType=VARCHAR},MESSAGE = #{item.message,jdbcType=VARCHAR},  BIZ_TRANSACTION_ID = #{item.bizTransactionId,jdbcType=INTEGER},UPDATE_TIME = #{item.updateTime,jdbcType=TIMESTAMP}</set>WHERE ID = #{item.id}</foreach>   </update>


0 0