MybatisPlus报错can not find lambda cache for this entity

BaseMapper的<你自己的实体类对象>,因为我是多表查询使用了vo,但是泛型还是Entiy而不是自己的vo类,才导致这个报错

问题代码


@Repository
public interface BlogMapper extends BaseMapper<SearchBlog> {

    //普通查询
    //@Select(querySql)
    List<SearchBlogVo> list(@Param(Constants.WRAPPER) QueryWrapper<SearchBlogVo> ew);
    
}

正确代码


@Repository
public interface BlogMapper extends BaseMapper<SearchBlogVo> {

    //普通查询
    //@Select(querySql)
    List<SearchBlogVo> list(@Param(Constants.WRAPPER) QueryWrapper<SearchBlogVo> ew);
    
}

你的service层接口的泛型也是需要修改的,

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wuxianggujun.wuxiangblog.mapper.BlogMapper;
import com.wuxianggujun.wuxiangblog.service.BlogService;
import com.wuxianggujun.wuxiangblog.vo.SearchBlogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogServiceImpl extends ServiceImpl<BlogMapper, SearchBlogVo> implements BlogService {
    private BlogMapper blogDao;

    @Autowired
    public void setBlogDao(BlogMapper blogDao) {
        this.blogDao = blogDao;
    }

    @Override
    public List<SearchBlogVo> searchBlog(String title) {

        QueryWrapper<SearchBlogVo> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(SearchBlogVo::getTitle, "文章");

        List<SearchBlogVo> searchBlogVos = blogDao.list(queryWrapper);

//
//        LambdaQueryWrapper wrapper = Wrappers.lambdaQuery(User.class).eq(User::getUsername, title);
//        //先查询用户数据
//        User user = userMapper.selectOne(wrapper);

        return searchBlogVos;
    }
}

你可能感兴趣的:(SpringBoot,mybatis-plus,java,开发语言)