Mybatis-Spring icon indicating copy to clipboard operation
Mybatis-Spring copied to clipboard

deleteByExample,updateByExample的坑

Open ting4937 opened this issue 5 years ago • 2 comments

deleteByExample,updateByExample的时候如果Criteria指定的条件为null会忽略该条件,这会导致数据大批量删除或更新,造成很大的安全隐患,相信很多人都不会注意这个问题,建议作者在传入的条件数据为null时不要忽略该条件

ting4937 avatar Jul 09 '19 01:07 ting4937

你不传默认就是null。。。你传了还是null。。。可以改成空串啊,再说了数据库也不建议用null

| | dc630638147 | | 邮箱:[email protected] |

Signature is customized by Netease Mail Master

在2019年07月09日 09:50,Cloud 写道:

deleteByExample,updateByExample的时候如果Criteria指定的条件为null会忽略该条件,这会导致数据大批量删除或更新,造成很大的安全隐患,相信很多人都不会注意这个问题,建议作者在传入的条件数据为null时不要忽略该条件

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

dc630638147 avatar Jul 09 '19 10:07 dc630638147

有两个 safeDelete 和 safeUpdate 参数,可以避免全表操作。

abel533 avatar Jul 11 '19 14:07 abel533