Myabtis批量更新报错记录

在项目中尝试使用Mybatis foreach 更新多条记录时遇到错误,通过发现Mybatis不支持一次性插入多条SQL的问题,解决方法是在database.url中添加allowMultiQueries=true。
摘要由CSDN通过智能技术生成

近期在项目中遇到一个需要批量更新的场景,因此想到了使用Mybatis的 foreach 标签来完成,Mapper里的sql如下:

<update id="" parameterType="java.util.List">
        <foreach collection="list" item="item"  separator=";" >

            update xxxx
            set enabled = 1
            <where>
            task_code=#{item.xxx} and apply_tenant_num=#{item.xx}
            </where>
            </foreach>
    </update>

通过插件获取到sql语句,没发现什么问题,但一直报如下错误:

### The error may involve org.srm.adaptor.infra.mapper.xxxxMapper.xxxxx-Inline
### The error occurred while setting parameters

一直查不出错误,后面发现正常情况下Mybatis是不支持一次性插入多条SQL的,如果想要支持这个功能,需要在 database.url中添加**&allowMultiQueries=true**来进行支持,添加这个设置后,问题解决

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值