mybatis的批量update操作写法很简单,如下:

public interface YourMapper extends BaseMapper<YourExt> {

    void updateBatch(@Param("pojos") Collection<YourExt> pojos);
}
    <update id="updateBatch" parameterType="java.util.Collection">
<foreach collection="pojos" item = "pojo" separator= ";" >
update your_table t set pt.your_value = #{pojo.yourValue} where pt.id = #{pojo.id}
</foreach>
</update>

在执行过程中报异常,但是sql和参数直接在DB里执行是好的,原因是MySql默认不支持批量更新,需要开发人员主动设置,只需要在你的数据库连接url后面加上

&allowMultiQueries=true

就好了

例如我的数据库连接配置就会变成

												

mybatis批量update操作的写法,及批量update报错的问题解决方法的更多相关文章

  1. 【centOS】【xshell】xshell连接虚拟机上的centOS,操作途中突然断开连接,报错:connect closed by foreign host

    如题  xshell连接虚拟机上的centOS,操作途中突然断开连接,报错:connect closed by foreign host 快捷解决方法: 在虚拟机上centOS重新启动网络,即可解决问 ...

  2. mysql执行update报错1175解决方法

    mysql执行update报错 update library set status=true where 1=1 Error Code: 1175. You are using safe update ...

  3. java 之 MyBatis(sql 可以执行,在eclipse执行报错问题)

    前段时间写 mybatis Sql 查询语句的时候,发现一个很奇怪的现象,我写的SQL 语句在 pl/Sql 中明明可以执行,但是放到 eclipse 中执行却报错,因为时间比较久,依稀记得是文字与字 ...

  4. pod update报错(Cocoapods: Failed to connect to GitHub to update the CocoaPods/Specs specs repo)报错解决方案

    好长一段时间没动pods,今天偶然需要更新一个库,于是执行了下pod update,然后惊悚的出现了这个报错: [!] Failed to connect to GitHub to update th ...

  5. mybatis批量更新update-设置多个字段值 报错 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

    mybatis批量更新update-设置多个字段值 2016年08月01日 12:49:26 姚一号 阅读数:29539 标签: mysql mybatis批量更新批量更新allowMultiQuer ...

  6. Oracle merge into 语句进行insert或者update操作,如果存在就update,如果不存在就insert

    merge into的形式:    MERGE INTO [target-table] A USING [source-table sql] B ON([conditional expression] ...

  7. mybatis配置文件,注意标签配置顺序。否则报错The content of element type "configuration" must match "(properties?,settings?,...怎么解决

    感谢原作者http://www.cnblogs.com/zhoumingming/p/5417014.html 注意每个标签必须按照顺序写,不然就会提示错误 顺序是 <?xml version= ...

  8. springboot集成报错,想要集成tk.mybatis报错,反射方法异常

    在添加注释 @MapperScan("com.leyou.item.mapper")的时候,如果不小心就会导包倒错应该导成 import tk.mybatis.spring.ann ...

  9. mybatis/tk mybatis下实体字段是关键字/保留字,执行报错

    实体如下: import com.fasterxml.jackson.annotation.JsonFormat; import com.xxx.web.bean.PagesStatic; impor ...

随机推荐

  1. YOLOv3测试命令

    一.老规矩 在darknet\build\darknet\x6下按住shift键,点击鼠标右键选择“在此处打开Powershell 窗口(s)” 二.测试图片命令: .\darknet detect ...

  2. JavaScript - 如果...没有方法(xjl456852修改)

    本文是对下面这篇文章中存在的错误进行修改,并增加少量注释. 原文出处: JavaScript - 如果...没有方法 http://www.cnblogs.com/silin6/p/4367019.h ...

  3. codeforces 363B

    #include<stdio.h> #include<string.h> #define inf 999999999 #define N 151000 int a[N],c[N ...

  4. Spring data jpa 复杂动态查询方式总结

    一.Spring data jpa 简介 首先我并不推荐使用jpa作为ORM框架,毕竟对于负责查询的时候还是不太灵活,还是建议使用mybatis,自己写sql比较好.但是如果公司用这个就没办法了,可以 ...

  5. VIM使用技巧15

    在vim的插入模式下,有时需要插入寄存器中的文本: 1.使用<C-r>{register} 2.使用<C-r><C-p>{register} 3.使用<C-r ...

  6. sqlserver2008 存储过程使用表参数

    ----首先,我们定义一个表值参数类型,其实就是一个表变量   Create type dbo.tp_Demo_MultiRowsInsert as Table   (   [PName] [Nvar ...

  7. [bzoj4827][Hnoi2017]礼物_FFT

    礼物 bzoj-4827 Hnoi-2017 题目大意:给定两个长度为$n$的手环,第一个手环上的$n$个权值为$x_i$,第二个为$y_i$.现在我可以同时将所有的$x_i$同时加上自然数$c$.我 ...

  8. MongoDB学习day03--索引和explain分析查询速度

    一.索引基础 db.user.ensureIndex({"username":1}) 创建索引,username为key,数字 1 表示 username 键的索引按升序存储, - ...

  9. Builder设计模式

    Builder模式,又称生成器或构建者模式,属于对象创建型模式,侧重于一步一步的构建复杂对象,只有在构建完成后才会返回生成的对象.Builder模式将一个复杂对象的构建与它的表示分离,使得同样的构建过 ...

  10. php-fpm配置项

    php版本:php-7.3 全局配置 ;;;;;;;;;;;;;;;;;;;;; ; FPM Configuration ; ;;;;;;;;;;;;;;;;;;;;; ; All relative ...