- 执行逻辑删除后的查询,sql语句会自动添加 逻辑删除字段的判断。当逻辑删除的字段 deleted =0(即未被删除) 才能被查到。 ```java package com.wzy.bootmtp.test;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.wzy.bootmtp.mapper.UserMapper; import com.wzy.bootmtp.pojo.User; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner;
import java.util.Arrays; import java.util.List; import java.util.Map;
@RunWith(SpringRunner.class) @SpringBootTest public class TestSpringBoot {
@Autowired
private UserMapper userMapper;
@Test
public void test3(){
//逻辑删除
int result = userMapper.deleteById(6);
System.out.println(result);
//查询
List<User> users = userMapper.selectList(null);
users.forEach(user -> System.out.println("user"));
}
}
``` 输出结果与表中数据对比:
- 执行逻辑删除后的查询,sql语句会自动添加 逻辑删除字段的判断。当逻辑删除的字段 deleted =0 才能被查到。