05-Mybatis- perform a bulk update

Batch oracle and mysql database update configuration is not the same in mybatis in:

oracle database:

<update id="batchUpdate"  parameterType="java.util.List">
       <foreach collection="list" item="item" index="index" open="begin" close="end;" separator=";">
                update test 
                <set>
                  test=${item.test}+1
                </set>
                where id = ${item.id}
       </foreach>
    </update>

mysql database:

mysql database using wording about to perform, but you must configure the database connection: & allowMultiQueries = true

例如: jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&amp;characterEncoding=UTF-8&allowMultiQueries=true

<update id="batchUpdate"  parameterType="java.util.List">
          <foreach collection="list" item="item" index="index" open="" close="" separator=";">
                update test 
                <set>
                  test=${item.test}+1
                </set>
                where id = ${item.id}
         </foreach>
    </update>

 

Guess you like

Origin www.cnblogs.com/ming311/p/10977932.html