一、mybatis执行批量更新batch update 的方法(mysql数据库)

1、数据库连接必须配置:&allowMultiQueries=true(切记一定要加上这个属性,否则会有问题,切记!切记!切记!)
  我的配置如下:jdbc:mysql://127.0.0.1:3306/test?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>
3、java 接口
  /**
* 批量修改赛程
*
* @param matchs
* @throws DaoException
*/
void updateMatchs(@Param(value = "matchs")List<MatchBasic> matchs);

二、mybatis执行批量更新batch update 的方法(oracle数据库)

1、批量修改并加判断条件(修改字段可选)

<update id="batchUpdateSplitSinglePickCurrency" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
UPDATE ZC_TR_MULTI_ORDER_CURRENCY
<set>
<if test="item.sysCorderCode != null">
SYS_CORDER_CODE = #{item.sysCorderCode,jdbcType=VARCHAR},
</if> <if test="item.sysPorderCode != null">
SYS_PORDER_CODE = #{item.sysPorderCode,jdbcType=VARCHAR},
</if> <if test="item.bizPorderCode != null">
BIZ_PORDER_CODE = #{item.bizPorderCode,jdbcType=VARCHAR},
</if> <if test="item.originalOrderCode != null">
ORIGINAL_ORDER_CODE = #{item.originalOrderCode,jdbcType=VARCHAR},
</if> <if test="item.splitUserId != null">
SPLIT_USER_ID = #{item.splitUserId,jdbcType=VARCHAR},
</if> <if test="item.createDate != null">
CREATE_DATE = #{item.createDate},
</if> <if test="item.updateDate != null">
UPDATE_DATE = #{item.updateDate},
</if>
</set>
where id = #{item.id,jdbcType=VARCHAR}
</foreach>
</update>

2、java接口

  /**
* @Desc : 批量更新大批量子订单详情信息
* @Author : ZRP
* @Date : 2018/1/26 15:24
*/
int batchUpdateSplitSinglePickCurrency(@Param(value = "list") List<MultiOrderCurrency> list) throws Exception;
PS:一定要注意文中标红色的地方

最新文章

  1. apache httpclient cache 实现可缓存的http客户端
  2. 判断https
  3. [MySql] - 解决部署的服务器没有安装MySql Connector
  4. mouseover与mouseenter与mousemove的区别mouseout与mouseleave的区别
  5. UE4中FString转UTF8及UTF8转FString
  6. eShopOnContainers 看微服务⑤:消息通信
  7. Delphi如何处理在进行大量循环时,导致的应用程序没有响应的情况
  8. 高性能场景下,HashMap的优化使用建议
  9. aliyun添加数据盘parted方式分区格式化和lvm挂载及数据盘的扩容
  10. oracle主键约束、唯一键约束和唯一索引的区别
  11. WebService—CXF—实现接口发布和客户端调用
  12. HTML5学习笔记 Geolocation(地理定位)
  13. jquery判断元素的子元素是否存在
  14. Binder Native 层(二)
  15. Jmeter实例计划(查询天气)
  16. 注册COM组件cmd(管理员权限)
  17. HDU 6034 6038
  18. linux编译动态库 fPIC作用
  19. next_permutatio
  20. Python编程-网络编程进阶(IO复用、Socketserver)

热门文章

  1. Swift学习笔记(十四)——字符,常量字符串与变量字符串
  2. 【Mac使用系列】【转载】十几个Mac实用工具
  3. windows IOCP入门的一些资料
  4. JProfiler进行Java运行时内存分析
  5. Python gensim库word2vec 基本用法
  6. django admin list_filter的使用
  7. JsonCpp 的使用
  8. js实现禁止pc端浏览器缩放和获取当前页面浏览器的缩放大小
  9. Ansible and FileBeta
  10. java中的数据加密5 数字证书