mybatis抛出异常的返回值
时间: 2023-11-26 10:49:30 浏览: 74
MyBatis在执行select语句时,如果没有在Mapper映射文件中显示声明返回值类型,会抛出异常,指出"A query was run and no Result Maps were found for the Mapped Statement"。\[3\]这意味着在Mapper映射文件中必须指定返回值类型,且该返回值类型需要与Mapper接口中声明的返回值类型一致,可以是Integer、Long、int或long,但不能返回Boolean类型。\[3\]对于insert、update、delete语句,MyBatis会使用rowCountResult方法对返回值进行转换,如果返回的值大于0,则返回True,否则返回False。\[1\]对于query函数,如果工程配置的defaultExecutorType是REUSE,MyBatis会使用ReuseExecutor的doQuery方法进行查询,但无法确定list返回是否为null。\[2\]
#### 引用[.reference_title]
- *1* *3* [MyBatis中Mapper的返回值类型](https://blog.csdn.net/tantiao666/article/details/106344829)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [探索Mybatis中Mapper默认返回值](https://blog.csdn.net/zhuqiuhui/article/details/87899146)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文