abel533 / MyBatis-Spring-Boot

Spring Boot集成MyBatis的基础项目
3.37k stars 1.59k forks source link

使用Example方法扔报错 #82

Closed delu-mengyu closed 6 years ago

delu-mengyu commented 6 years ago

你好,前辈,在你的博客上下载的最新代码, default 仍然有org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'distinct' in 'class tk.mybatis.springboot.model.UserInfo' 这个错误,

delu-mengyu commented 6 years ago

@abel533

abel533 commented 6 years ago

注意所有 Example 相关方法的参数都是 Example 类型。

delu-mengyu commented 6 years ago

你好前辈,问题已解决了,还是自己的查询参数有问题.........

liuguichuan666 commented 6 years ago

nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'distinct' in 'class tk.mybatis.mapper.entity.Example$Criteria' , 我也报了这种错误,我是想在city里也用cityMapper.selectByExample(criteria); 这是什么情况啊

delu-mengyu commented 6 years ago

Example 相关方法的参数都是 Example 类型。要注意类型的转换,这样写试试

public List getInfoByExample(String productName, byte productType) { Example example = new Example(Product.class); Example.Criteria criteria = example.createCriteria(); //你的条件参数 criteria.andEqualTo("productName", productName); criteria.andEqualTo("productType", productType); List proList = productMapper.selectByExample(example); logger.info("根据Example获取 {}", proList); return proList; }

liuguichuan666 commented 6 years ago

额,是我写错了,我传的是criteria,谢谢啦