下午客户反馈数据对不上,去线上数据库发现所有砖表状态都在下午两点半被改为异常状态,推测是执行批量修改没有传where参数,还有周六有备份把数据恢复了一下,下面是问题代码
<update id="batchUpdate">
update production_plan_brick
<include refid="Base_Set"/>
<foreach collection="list" item="param" open=“where” separator=" or " close="">
(plan_no = #{param.planNo,jdbcType=VARCHAR} and serial_num = #{param.serialNum,jdbcType=VARCHAR} and
status = #{param.status,jdbcType=INTEGER})
</foreach>
</update>
open=“where”应抽到前面,避免如果集合没有数据导致where条件后没数据批量更新全部
调用别人的模块代码时,审查一下代码逻辑,避免问题,同时判断自己的业务代码
网友评论