项目场景:
前几天在写项目中的Mapper的时候,遇到了这种报错,在这里记录一下。免得以后忘记。
问题描述
在项目中的Mapper使用了如下的写法。
where xx.isDeleted = #{isDeleted} and 1=1 and ..
出现了如下的错误
sql injection violation, part alway true condition not allow
原因分析:
1=1 不能永真条件
ql injection violation, part alway true condition not allow
解决方案:
将SQL永真(1=1类似的)的条件放到第一位 或者 去掉