.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 8(String)
时间: 2023-10-22 21:02:54 浏览: 156
这个错误是org.apache.ibatis.exceptions.PersistenceException,可能有两个原因导致。首先,可能是因为业务需求需要返回一个List集合,但你返回的是一个对象。这可能导致查询结果包含了多条数据,而你只期望返回一条结果或者null,这就会抛出异常。其次,可能是数据库中存在重复的数据,导致查询结果不止一个。在Mybatis无法确定返回哪个结果时,也会抛出异常。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Mybatis报错: org.apache.ibatis.exceptions.PersistenceException解决办法](https://download.csdn.net/download/weixin_38500709/13701351)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [关于Mybatis异常:org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null)...](https://blog.csdn.net/m0_60232519/article/details/122885135)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文