Expected one result (or null) to be returned by selectOne(), but found: 6

Posted 闲言_

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Expected one result (or null) to be returned by selectOne(), but found: 6相关的知识,希望对你有一定的参考价值。

错误产生环境

mybatis查询数据时产生

错误描述

Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 6
	at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:81)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
	... 35 more

错误原因

  • 使用mybatis查询的时候返回数据的属性使用错误
  • 本来想使用resultMap的 结果使用到了resultType

解决办法

  • 改正即可

以上是关于Expected one result (or null) to be returned by selectOne(), but found: 6的主要内容,如果未能解决你的问题,请参考以下文章

TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2(代

Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be

Expected one result (or null) to be returned by selectOne(), but found: 2

Expected one result (or null) to be returned by selectOne(), but found: 2 和 java.lang.UnsupportedOp

Expected one result to be returned by selectOne,but found: 2

问题解决nested exception is org.apache.ibatis.exceptions.TooManyResultException:Expected one result