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>

 

posted @ 2022-08-30 10:46  xiexie0812  阅读(326)  评论(0编辑  收藏  举报