can not find lambda cache for this property [name] of entity [xxx.xxx.xxx.TbUser]

service层的业务代码如下:

@Override
public List<TbUser> getUserList(String keywords) {
    QueryWrapper<TbUser> queryWrapper = new QueryWrapper<>();
    LambdaQueryWrapper<TbUser> lambda = queryWrapper.lambda();
    lambda.like(TbUser::getName, keywords).or()
            .like(TbUser::getProfession, keywords)
    ;
    List<TbUser> list = this.list(lambda);
    return list;
}

mybatis-plus执行报错:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression ‘ew.sqlSegment != null and ew.sqlSegment != ‘’ and ew.nonEmptyOfWhere’. Cause: org.apache.ibatis.ognl.OgnlException: sqlSegment [com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this property [name] of entity [com.fuyan.entity.TbUser]]] with root cause
com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: can not find lambda cache for this property [name] of entity [com.fuyan.entity.TbUser]

原因:
不能在lambda缓存中找到某个实体类中的name字段;
查看TbUser这个实体类,发现name字段加上了@TableField(exist = false)注解,表示当前属性不是数据库的字段
在这里插入图片描述
解决方法:
不能对标注有@TableField(exist = false)的属性字段进行条件查询,把name属性上面的@TableField(exist = false)注解去掉即可

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值