当前使用版本(必填,否则不予处理)
mybatis plus 3.2.0
该问题是如何引起的?(确定最新版也有问题再提!!!)
我想在接口参数中传递 LambdaQueryWrapper 的查询条件,但是报错了
原始代码如下:
`
@Override
@Transactional(rollbackFor = Exception.class)
public int addUpdate(UserUpdateVO saveUpdateVO) {
isExist2(1L, UserUpdateVO::getUserName, "22");
return 0;
}
private boolean isExist2(Long id, SFunction sFunction, String columnValue) {
LambdaQueryWrapper
我知道使用QueryWrapper可以,但是我想用lambda的方式,我该如何修改代码?
重现步骤(如果有就写完整)
报错信息
isExist2(1L, UserUpdateVO::getUserName, "22");
编译报错
Non-static method cannot be referenced from a static context
Comment From: spenie
private boolean isExist2(Long id, SFunction
Comment From: CodingSoldier
private boolean isExist2(Long id, SFunction
sFunction, String columnValue) { LambdaQueryWrapper lqw = new LambdaQueryWrapper<>(); lqw.eq(sFunction, columnValue); lqw.ne(UserUpdateVO::getIsDel, false); if (Objects.nonNull(id)) { lqw.ne(UserUpdateVO::getId, id); } return count(lqw) > 0; }
感谢,管用。
这是什么原理?
为啥加上 SFunction
Comment From: VampireAchao
需指定函数式接口的泛型,否则编译器无法推断到底是哪款函数式接口