mybatis执行批量更新batch update 的方法
1、数据库连接必须配置:&allowMultiQueries=true
我的配置如下:jdbc:mysql://10.20.13.16:3306/CALENDAR?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
2、批量修改并加判断条件(修改字段可选)
<!-- 批量更新赛程 -->
<update id="updateMatchs" parameterType="java.util.List">
<foreach collection="matchs" item="item" index="index" open="" close="" separator=";">
update t_match
<set>
<if test="item.title !=null">
TITLE = #{item.title,jdbcType=VARCHAR},
</if>
<if test="item.homeScore !=null">
HOME_SCORE = #{item.homeScore,jdbcType=INTEGER},
</if>
<if test="item.visitScore !=null">
VISTT_SCORE = #{item.visitScore,jdbcType=INTEGER},
</if>
<if test="item.liveSource !=null">
LIVE_SOURCE = #{item.liveSource,jdbcType=VARCHAR},
</if>
<if test="item.liveURL !=null">
LIVE_URL = #{item.liveURL,jdbcType=VARCHAR},
</if>
<if test="item.isHotMatch !=null">
IS_HOT_MATCH = #{item.isHotMatch,jdbcType=VARCHAR}
</if>
</set>
where HOME_TEAM_ID = #{item.homeTeamId,jdbcType=VARCHAR} and
VISIT_TEAM_ID = #{item.visitTeamId,jdbcType=VARCHAR} and
MATCH_TIME = #{item.matchTime,jdbcType=BIGINT}
</foreach>
</update>
java接口
/**
* 批量修改赛程
*
* @param matchs
* @throws DaoException
*/
void updateMatchs(@Param(value = "matchs")List<MatchBasic> matchs);
mybatis执行批量更新batch update 的方法的更多相关文章
- mybatis执行批量更新update
Mybatis的批量插入这里有http://ljhzzyx.blog.163.com/blog/static/38380312201353536375/.目前想批量更新,如果update的值是相同的话 ...
- 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】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 ...
- oracle 批量更新之update case when then
oracle 批量更新之update case when then CreationTime--2018年8月7日15点51分 Author:Marydon 1.情景描述 根据表中同一字段不同情况 ...
- mybatis 的批量更新操作sql
转: mybatis 的批量更新操作sql 2018年07月23日 10:38:19 海力布 阅读数:1689 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.cs ...
- 【mybatis】mybatis中批量插入 批量更新 batch 进行insert 和 update,或者切割LIst进行批量操作
================================================================== 分别展示 mybatis 批量新增 和 批量更新 的操作: ...
- mysql批量update更新,mybatis中批量更新操作
在日常开发中,有时候会遇到批量更新操作,这时候最普通的写法就是循环遍历,然后一条一条地进行update操作.但是不管是在服务端进行遍历,还是在sql代码中进行遍历,都很耗费资源,而且性能比较差,容易造 ...
随机推荐
- ssh连接失败,排错经验
一.场景描述 ssh连接服务器,发现连接失败,但是对应服务器的ip能够ping通. 场景: [root@yl-web ~]# ssh root@10.1.101.35 ssh_exchange_ide ...
- 超链接a的target属性
<a>标签的target意思很明确就是在哪里打开目标文档. 第一种情况: 默认情况:当我们没有设置超链接属性target的value值时默认是_self,即<a target=&qu ...
- What makes an excellent front-end developer?(for my English speech)
What makes an excellent front-end developer? Let me please start this talking by saying that what is ...
- AC日记——加密的病历单 openjudge 1.7 12
12:加密的病历单 总时间限制: 1000ms 内存限制: 65536kB 描述 小英是药学专业大三的学生,暑假期间获得了去医院药房实习的机会. 在药房实习期间,小英扎实的专业基础获得了医生的一致 ...
- 接入Google Play SDK
更新 好消息:Unity5.3添加了google play.Mac .AppStore.windows store的IPA接口,我们做内购日后方便多啦!关于国内渠道的接入,推荐通用SDK平台,比如an ...
- 强加密RNGCryptoServiceProvider
.net RNGCryptoServiceProvider 对应 java SecureRandom public class SecureRandomextends Random This cla ...
- Nginx反向代理和负载均衡——个人配置
#user nobody; worker_processes 2; #error_log logs/error.log; #error_log logs/error.log notice; #erro ...
- [No000063]Python格式化输出
python print格式化输出. 1. 打印字符串 print ("His name is %s"%("Aviad")) 效果: 2.打印整数 print ...
- PHP提升echo, printf, print, file_put_contents等输出方法的效率
让ECHO变快, 让PHP的请求处理过程, 尽快结束, 之所以ECHO慢, 是在等待”写数据”成功返回, 那么一个比较简单的办法, 就是打开输出缓存, 编辑php.ini output_bufferi ...
- Ros学习注意点
编译问题 回调函数不能有返回类型,严格按照实例程序编写 第三方库的问题,packet.xml里面必须加上自己的依赖文件 之前文档里面介绍的有点问题. 主要表现在:当你建立包的时候就写入了依赖,那就不需 ...