首页  >  文章  >  数据库  >  mybatis执行批量更新batch update 的方法(oracle,mysql)_MySQL

mybatis执行批量更新batch update 的方法(oracle,mysql)_MySQL

WBOY
WBOY原创
2016-06-01 13:11:091257浏览

oracle和mysql数据库的批量update在mybatis中配置不太一样:

oracle数据库:

<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数据库:

mysql数据库采用一下写法即可执行,但是数据库连接必须配置:&allowMultiQueries=true

例如:jdbc:mysql://192.168.1.236:3306/test?useUnicode=true&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>


 

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn