开发者

Mybatis使用foreach批量更新数据报无效字符错误问题

目录
  • 使用pythonforeach批量更新数据报无效字符错误
    • 改动前
    • 改动后:(加了begin,end)
  • MyBATis报“无效字符”的错的原因
    • 原因是
  • 总结

    使用fornaFGxJVeach批量更新数据报无效字符错误

    改动前

    <update id="updateByECBoxIdBatch" parameterType="Java.util.List">
        <foreach collection="list" item="itemnaFGxJV" index="index" open="" close=";" separator=";">
            update EC_ENTRUST_BOX
            set REALMONEY = #{item.money,jdbcType=DECIMAL}
            where BOX_ID = #{item.boxId,jdbcType=VARCHAR}
            and ENTRUST_MONEY_ID = #{item.ecEntrustMoneyId,jdbcType=VARCHAR}
        </foreach>
    </update>

    后台执行的SQL:

    update EC_ENTRUST_BOX
    set REALMONEY = ?
    where BOX_ID = ?
    and ENTRUST_MONEY_ID = ?
    ;
    update EC_ENTRUST_BOX
    set REALMONEY = ?
    where BOX_ID = ?
    and jsENTRUST_MONEY_ID = ?
    ;
    update EC_ENTRUST_BOX
    set REALMONEY = ?
    where BOX_ID = ?
    and ENTRUST_MONjsEY_ID = ?
    ;

    报错:无效字符

    改动后:(加了begin,end)

    <update id="updateByECBoxIdBatch" parameterType="java.util.List">
        <foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";">
            update EC_ENTRUST_BOX
            set REALMONEY = #{item.money,jdbcType=DECIMAL}
            where BOX_ID = #{item.boxId,jdbcType=VARCHAR}
            and ENTRUST_MONEY_ID = #{item.ecEntrustMoneyId,jdbcType=VARCHAR}
        </foreach>
    </update>

    后台执行的SQL:

    begin
    update EC_ENTRUST_BOX
    set REALMONEY = ?
    where BOX_ID = ?
    and ENTRUST_MONEY_ID = ?
    ;
    update EC_ENTRUST_BOX
    set REALMONEY = ?
    where BOX_ID = ?
    and ENTRUST_MONEY_ID = ?
    ;
    update EC_ENTRUST_BOX
    set REALMONEY = ?
    where BOX_ID = ?
    and ENTRUST_MONEY_ID = ?
    ;end;

    正常执行~~~~~~~~

    Mybatis报“无效字符”的错的原因

    mybatis报ORA-00911: 无效字符。

    原因是

    在mapper配置中有“;”

    总结

    以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程客栈(www.devze.com)。

    0

    上一篇:

    下一篇:

    精彩评论

    暂无评论...
    验证码 换一张
    取 消

    最新开发

    开发排行榜