根据报错信息,可以看出 SQL 语句中存在语法错误。

具体原因是在 <foreach> 标签中,使用了错误的写法。在 <foreach> 标签中,使用了 itemcollection 属性,这意味着在 <foreach> 标签中的 SQL 语句中,需要引用 item 来代表集合中的每个元素。

解决方法是将 <foreach> 标签中的 #{id} 改为 #{item},即将 #{id} 改为 #{item}

修改后的代码如下:

<update id="auditApply">
    update t_d_nvfillformreportapply
    <trim prefix="SET" suffixOverrides=",">
        <!-- 此处写删除处理 -->
        <if test="status != null">C_STATUS = #{status},</if>
        <if test="person != null">C_COUNAMEPERSON = #{person},</if>
        <if test="content != null">C_COUCONTENT = #{content},</if>
        C_COUAT=Date()
    </trim>
    <where>
       C_ID in
        <foreach item="item" collection="ids" open="(" separator="," close=")">
            #{item}
        </foreach>
        and (C_STATUS = 0 or C_STATUS = 4) AND C_DELETED=0
    </where>
</update>

修改后重新执行应该就不会报错了。

MyBatis 中的 `foreach` 语法错误:如何解决 `java.sql.SQLSyntaxErrorException`

原文地址: https://www.cveoy.top/t/topic/pfrU 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录