org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2

org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
功能:查询数据库当前用户是否存在

错误原因 :本人数据库有两条相同的数据

由错误提示可知,查询的结果是期望一条记录或者为空,但是返回的记过有2条,也就是说你的sql查询结果返回多条了

解决办法

(1)检查Mybatis配置文件中返回的结果类型与Java中返回类型是否一致

(2)检查传递参数的个数
(3)检查数据库数据是否正确

(4)检查映射SQL中返回resultType 或resultMap,接口里的返回类型

(5)select语句加上limit 1

(6)…

已解决
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
更多博客分享

相关文章:

  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2021-08-02
  • 2021-05-31
  • 2022-12-23
猜你喜欢
  • 2021-11-06
  • 2022-12-23
  • 2021-10-31
  • 2021-09-09
  • 2021-08-02
相关资源
相似解决方案