mybatis ~ 批量更新(sql循环)update foreach

今天要做批量更新的业务,采用mybaits的foreach动态语句,遇到一些问题做下记录。


<update id=""  parameterType="">
    <foreach collection="list" item="item" index="index">
    update tb_question_template_seleteitem_detail set selectedName=#{item.selectedName}
    where 1=1 and  selectedId =#{item.selectedId  };
    </foreach>
</update>

这种情况一半会报错,解决方式:在数据库配置上添加 &allowMultiQueries=true

例如:jdbc:mysql://192.168.1.109:3306/healthmanage?characterEncoding=utf-8&allowMultiQueries=true

参考:https://my.oschina.net/zhuguowei/blog/411853

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容