Mybatis 中Expected one result (or null) to be returned by selectOne(), but found: 5

来源:互联网 发布:汤姆克鲁斯 知乎 编辑:程序博客网 时间:2024/04/29 01:09

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 4 

 

到这个错误的原因就是因为你的查询方法中得到两个两个结果集,然而你的返回用了一个实体去接收,程序这个时候就不知道如何去分配了,很果断的报这个错,

修改方法为使用一个list来接收就没有问题了。


0 0