改动前:
<update id="updateByECBoxIdBatch" parameterType="java.util.List">
<foreach collection="list" item="item" 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 ENTRUST_MONEY_ID = ?
;
update EC_ENTRUST_BOX
set REALMONEY = ?
where BOX_ID = ?
and ENTRUST_MONEY_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;
正常执行。特此记录。