当前使用版本

3.4.3.2

该问题是如何引起的?

mapper.xml 中重写 selectPage 方法后,查询时,queryWrapper如果使用entity构造方法。查询条件会被忽略。

重现步骤

//查询

IPage<User> userPage = new Page<>(1, 1);
User u=new User();
u.setId(24L);
QueryWrapper queryWrapper=Wrappers.query(u);
return ApiResponse.success(userMapper.selectPage(userPage,queryWrapper));

//xml中重写
 <select id="selectPage" resultType="User">
        select * from user ${ew.customSqlSegment}
 </select>

报错信息

//没有查询条件
==>  Preparing: SELECT COUNT(*) FROM user
==> Parameters: 

测试截图

MyBatis-Plus mapper.xml 中重写 selectPage 方法后。查询时,queryWrapper如果使用entity构造方法。查询条件会被忽略。

Comment From: miemieYaho

自己写的不支持