创建条件构造器传入实体对象时,没有设置主键值,查询SQL日志显示主键值为0
/** * 创建条件构造器时传入实体对象 */ @Test public void selectByWrapperEntity(){ User whereUser = new User(); whereUser.setName("Jack"); whereUser.setAge(20); QueryWrapper<User> queryWrapper = new QueryWrapper<User>(whereUser); List<User> userList = userMapper.selectList(queryWrapper); userList.forEach(System.out::println); }
##### SQL日志执行如下
==> Preparing: SELECT id,name,age,email FROM user WHERE id=? AND name=? AND age=?
==> Parameters: 0(Long), Jack(String), 20(Integer)
<== Total: 0