mybatis执行批量更新batch update 的方法
2016-06-15 11:34
393 查看
1、数据库连接必须配置:&allowMultiQueries=true
我的配置如下:jdbc:mysql://10.20.13.16:3306/CALENDAR?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true
2、批量修改并加判断条件(修改字段可选)
java接口
我的配置如下: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);
相关文章推荐
- scala学习笔记——操作符
- Java导出txt文件的方法
- java工具类-给定一个file实例将该目录下的文件以及目录输出
- nginx和php文件大小限制修改
- js实现文件上传预览功能
- openswan 配置文件详解
- Objective-C学习之NSValue
- 【转】linux Centos 6.5 安装桌面环境GNOME
- 在webView上添加视图
- 模式识别(Pattern Recognition)学习笔记(二十七)-- 基于树搜索算法的快速近邻法
- Android Matrix详解
- Linux 添加新硬盘
- SQLite的设计与概念
- 游标
- 导出下载多个Excel文件并打包成zip文件
- DRP(一)——servlet小例子
- Web Services的简单介绍
- 华为机试---最高分是多少
- JAVA 基础浅谈
- 导出mysql表结构到excel脚本