1、jdbc链接修改
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&rewriteBatchedStatements=true
jdbc.username=root
jdbc.password=root
2、批量插入
<insert id="INSERT_BATCH_HOTEL_REAL_PRICE" parameterType="java.util.List">
INSERT IGNORE INTO VST_HOTEL_REAL_TIME_PRICE (
PRODUCT_ID,
REAL_TIME_PRICE1,
REAL_TIME_PRICE2,
REAL_TIME_REMAIN1,
REAL_TIME_REMAIN2,
UPDATE_TIME
) VALUES
<foreach collection="list" item="item" index="index" separator=",">
(#{item.productId},
#{item.realTimePrice1},
#{item.realTimePrice2},
#{item.realTimeRemain1},
#{item.realTimeRemain2},NOW())
</foreach>
</insert>
3、批量修改
<update id="UPDATE_HOTEL_REAL_TIME_PRICE" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" separator=";">
UPDATE VST_HOTEL_REAL_TIME_PRICE
<set>
<if test="item.realTimePrice1 != null">
REAL_TIME_PRICE1 = #{item.realTimePrice1},
</if>
<if test="item.realTimePrice2 != null">
REAL_TIME_PRICE2 = #{item.realTimePrice2},
</if>
<if test="item.realTimeRemain1 != null">
REAL_TIME_REMAIN1 = #{item.realTimeRemain1},
</if>
<if test="item.realTimeRemain2 != null">
REAL_TIME_REMAIN2 = #{item.realTimeRemain2},
</if>
UPDATE_TIME = NOW()
</set>
WHERE PRODUCT_ID = ${item.productId}
</foreach>
</update>
原文地址:https://www.cnblogs.com/zhanh247/p/11510511.html