mapper.xml中的sql:
<update id="updateBatchCardNumber" parameterType="java.util.List">
<foreach collection="list" index="index" item="item" open="" separator=";" close="">
update apply_user
<set>
<if test="item.cardNumber!=null">
card_number = #{item.cardNumber,jdbcType=VARCHAR},
</if>
<if test="item.cardNumber!=null">
insurance_no = #{item.insuranceNo,jdbcType=VARCHAR}
</if>
</set>
<where>
<if test="item.id!=null">
id = #{item.id,jdbcType=BIGINT}
</if>
</where>
</foreach>
</update>
报错信息:
2020-07-07 18:29:04.166 DEBUG 11064 --- [nio-7900-exec-1] c.j.p.d.A.updateBatchCardNumber : ==> Preparing: update apply_user SET card_number = ?, insurance_no = ? WHERE id = ? ; update apply_user SET card_number = ?, insurance_no = ? WHERE id = ?
2020-07-07 18:29:04.239 ERROR 11064 --- [nio-7900-exec-1] c.j.f.c.b.e.GlobalExceptionHandler :
### Error updating database. Cause: java.sql.SQLException: sql injection violation, multi-statement not allow : update apply_user
SET card_number = ?,
insurance_no = ?
WHERE id = ?
;
update apply_user
SET card_number = ?,
insurance_no = ?
WHERE id = ?
解决办法:https://www.cnblogs.com/songanwei/p/9120593.html
由于暂时不能改数据配置,不然牵一发而动全身,所以最后只能一条条的执行了。