mybatis批量插入时报错:syntax error, expect ‘)‘
问题:
mybatis批量插入时报错:syntax error, expect ‘)’
解决:
是因为传入的参数list为null,在代码中加上list.size()>0
的判断。
mapper文件:
<insert id="batchInsertSysUserAssoc">
insert into sys_user_assoc(user_id, assoc_id, is_parent) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.userId},#{item.assocId},#{item.isParent})
</foreach>
</insert>
欢迎一起来学习和指导,谢谢关注!
本文来自博客园,作者:xiexie0812,转载请注明原文链接:https://www.cnblogs.com/mask-xiexie/p/16638514.html