主键id 不能使用 第2中方式 吗 ?
info -> info.getColumn().equals("id");
info -> info.getColumn().equals("id");
2019-07-17
query.select(User.class, !info->info.getColumn().equals("id"));
这样写排除不了id,结果集id还是会显示出来。
@Test public void selectPartOfColumns(){ QueryWrapper<User> qw = new QueryWrapper<>(); qw.like("name","雨").gt("age",20) .select(User.class,c -> !c.getColumn().equals("id") ); List<User> list = userMapper.selectList(qw); list.forEach(System.out::println); }
DEBUG==> Preparing: SELECT id,create_time,name,manager_id,email,age FROM user WHERE (name LIKE ? AND age > ?)
DEBUG==> Parameters: %雨%(String), 20(Integer)
TRACE<== Columns: id, create_time, name, manager_id, email, age
TRACE<== Row: 1094590409767661570, 2019-01-14 09:15:15, 张雨琪, 1088248166370832385, zjq@baomidou.com, 31
TRACE<== Row: 1094592041087729666, 2019-01-14 09:48:16, 刘红雨, 1088248166370832385, lhm@baomidou.com, 32
DEBUG<== Total: 2
User(id=1094590409767661570, name=张雨琪, age=31, email=zjq@baomidou.com, managerId=1088248166370832385, createTime=2019-01-14T09:15:15)
User(id=1094592041087729666, name=刘红雨, age=32, email=lhm@baomidou.com, managerId=1088248166370832385, createTime=2019-01-14T09:48:16)
举报