mybatis执行批量更新update
Mybatis的批量插入这里有http://ljhzzyx.blog.163.com/blog/static/38380312201353536375/。目前想批量更新,如果update的值是相同的话,很简单,组织
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>
------------------------------------------------------------------------------------------------------------------------------
https://my.oschina.net/zouqun/blog/405424
--------------------------------------------------------------------------------------------------------------------------------
版权声明:本文为博主原创文章,未经博主允许不得转载。
<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
update tmi_licai_all t
set
t.est_amount=#{item.estAmount,jdbcType=NUMERIC}
where t.licai_id = #{item.licaiId,jdbcType=NUMERIC}
</foreach>
</update>
mybatis执行批量更新update的更多相关文章
- mybatis执行批量更新batch update 的方法
1.数据库连接必须配置:&allowMultiQueries=true 我的配置如下:jdbc:mysql://10.20.13.16:3306/CALENDAR?useUnicode=tru ...
- mybatis执行批量更新数据
1.业务需求:同时执行多记录批量操作 2.实现方法: 1)mapping: 2) dao 层 3)Service 层(注意要使用Transactional,否则可能会导致数据紊乱) 4)Con ...
- 170829、mybatis使用oracle和mybatis中批量更新
一.mybatis执行批量更新batch update 的方法(mysql数据库) 1.数据库连接必须配置:&allowMultiQueries=true(切记一定要加上这个属性,否则会有问题 ...
- 如何 ︰ 执行批量更新和插入使用.NET 提供程序在 C#.NET OpenXML
https://support.microsoft.com/zh-cn/kb/315968 如何 ︰ 执行批量更新和插入使用.NET 提供程序在 C#.NET OpenXML Email Prin ...
- mybatis 的批量更新操作sql
转: mybatis 的批量更新操作sql 2018年07月23日 10:38:19 海力布 阅读数:1689 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.cs ...
- 【mybatis】mybatis进行批量更新,报错:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right
使用mybatis进行批量更新操作: 报错如下: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an erro ...
- Myabtis中批量更新update多字段
在mybatis中批量更新多个字段 推荐使用如下操作: 方式1:在Dao层接口中: void updateBatch(@Param("list")List<Student&g ...
- Mysql 批量更新update的表与表之间操作
Mysql 批量更新update的表与表之间操作 一.方法一 使用User2表数据更新User表: update User as a ,User2 as b set a.role_id=b.set_v ...
- mysql批量update更新,mybatis中批量更新操作
在日常开发中,有时候会遇到批量更新操作,这时候最普通的写法就是循环遍历,然后一条一条地进行update操作.但是不管是在服务端进行遍历,还是在sql代码中进行遍历,都很耗费资源,而且性能比较差,容易造 ...
随机推荐
- 服务 在初始化安装时发生异常:System.IO.FileNotFoundException: "file:///D:\testService"未能加载文件或程序集。系统找不到指定文件。
@echo.@if exist "%windir%\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" goto INSTALL ...
- zend studio导入svn项目后不能代码提示的解决
把项目下.project的文件内容改成如下: <?xml version="1.0" encoding="UTF-8"?><projectDe ...
- pc wap 判断浏览器ua属性
var ua = navigator.userAgent.toLowerCase(); var Android = String(ua.match(/android/i)) == "andr ...
- 【java】之3种方式实现Object和Map之间的转换
利用commons.BeanUtils实现Obj和Map之间转换,这种是最简单,也是最经常用的 public static Object mapToObject(Map<String, Obje ...
- tokudb引擎磁盘空间不足导致写入失败的调查
故障现象 2016.1.1号早上4点左右,zabbi数据库服务器报警,写入数据失败.登陆机器后检查发现磁盘空间使用95%没有用满,进去zabbix数据库,执行insert命令提示错误“errir 10 ...
- 【总结】JS里的数组排序
虽然贴了2种办法,但是思路是一致的,都是先从数组里找出最小值,一种是找到一个放进新数组: 另一种是找到后和第i个数交换,i每次自增 主要用到2个函数: 从一个数组里找出最小值: 两个元素互换位置 fu ...
- linux socket连接中 ERRNO错误
Connection refused:应该是连接的服务端没有启动或者连接端口错误,可以用如下代码测试 client端: #include <stdio.h> #include <sy ...
- jquery “做页面滚动到某屏时改变状态标题” 所用知识点记录
浏览器滚动条滚动时触发事件 //浏览器滚动条滚动时触发事件 $(window).scroll(function(){}); 浏览器窗口大小改变时触发事件 //浏览器窗口大小改变时触发事件 $(wind ...
- Window服务安装方式汇总
一.制作bat文件 1)Install.bat: @echo 安装服务 %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\installutil AppS ...
- 集合类 toArray(T[])
HashSet<String> deDupe = new LinkedHashSet<>(Arrays.asList(origParams.getParams(paramNam ...