nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne()
时间: 2023-10-17 13:01:15 浏览: 173
登录发生问题提出:Expected one result (or null) to be returned by selectOne(), but found: 2
5星 · 资源好评率100%
nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2 是因为在执行sql语句查询时,返回了多条结果,但代码中只期望返回一条结果。这导致了问题的出现。解决这个问题有两种方法可以尝试。
方法一是在Dao层找到对应方法的Sql语句,将该语句复制到数据库中执行。根据注释中所需的字段,传入相应的参数运行Sql语句,查看查询到的数据。如果发现有多余的数据,可以删除这些多余的字段。然后重新发送请求,问题就可以解决了。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [ nested exception is org.apache.ibatis.exceptions.TooManyResultsException:Expected one result](https://blog.csdn.net/m0_61682705/article/details/125029333)[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_2"}}] [.reference_item style="max-width: 50%"]
- *2* [nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result](https://blog.csdn.net/gonnabehappy/article/details/124348041)[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_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文