Expected one result(or null)to be returned by selectOne()
时间: 2023-10-23 15:04:04 浏览: 176
求救!!mybatis Expected one result (or null) to be returned by selectOne(), but found:18
引用和提到了一个错误,即在运行测试文件时,程序报错"Expected one result (or null) to be returned by selectOne(), but found: 2"。这个错误通常是因为在数据库中找到了多条符合条件的数据,但是在返回结果时,只能返回一个数据,导致了该错误。引用则提到了具体的情况,即在mapper.xml中的select语句返回了一个数据列表,而在代码中的接收类型却是单个数据,所以当查询到60个数据时就会报错。所以,解决这个问题的方法就是要确保查询结果的返回类型与接收类型一致,或者在查询时限制只返回一条数据。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* *3* [错误解决:Expected one result (or null) to be returned by selectOne()](https://blog.csdn.net/weixin_69914772/article/details/130965968)[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^v92^chatsearchT3_1"}} ] [.reference_item]
- *2* [Expected one result (or null) to be returned by selectOne(), but found: 2的问题解决方法](https://blog.csdn.net/m0_54066656/article/details/124067673)[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^v92^chatsearchT3_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文