mybatis-plus逻辑删除数据后依然能够查出该数据

  • Post author:
  • Post category:其他




问题:逻辑删除后的数据依然能够查询的到



我的出错原因:

在pojo类中的@TableLogic注解中加了value属性,导致mybatis-plus生成的sql语句的条件一直是

where deleted=deleted

# 逻辑删除的sql
 UPDATE test_exercise.user SET deleted=1 WHERE id=? AND deleted=deleted
# 查询sql
 SELECT id AS userId,name AS userName,age AS userAge,email AS userEmail,sex AS userSex,deleted FROM test_exercise.user WHERE deleted=deleted



解决

在pojo中注解改为以下


//旧
@TableLogic("deleted")//逻辑删除
private Integer deleted;

//新
@TableLogic//逻辑删除
@TableField("deleted")
private Integer deleted;



版权声明:本文为isliucheng原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。