Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be
2017-11-10 22:29
996 查看
错误原因
(1)查询的结果是期望一条记录或者为空,但是返回的记录为多条数据
(2)结果返回两个结果集,然而返回用一个实体去接收,程序就不知道如何去分配了,所以报错
(3)查询返回的应该是一条记录,mybatis报错,显示查询了多条记录,发现数据库,里面有两条一样的数据,所以报错
解决办法
(1)检查Mybatis配置文件中返回的结果类型与Java中返回类型是否一致
(2)检查传递参数的个数
selectOne与selectList
selectOne:是用来接收一条结果集
selectList:是用来接收多条结果集,一般是用结果来接收。
如果返回的数据不只一条,但是使用了selectOne来接收结果集,那么就会抛出异常
接收的参数可以换成对应的集合类型,selectOne换成selectList
参考地址
http://blog.csdn.net/you23hai45/article/details/51427403?locationNum=5&fps=1 http://blog.csdn.net/a4171175/article/details/78018143
(1)查询的结果是期望一条记录或者为空,但是返回的记录为多条数据
(2)结果返回两个结果集,然而返回用一个实体去接收,程序就不知道如何去分配了,所以报错
(3)查询返回的应该是一条记录,mybatis报错,显示查询了多条记录,发现数据库,里面有两条一样的数据,所以报错
解决办法
(1)检查Mybatis配置文件中返回的结果类型与Java中返回类型是否一致
(2)检查传递参数的个数
selectOne与selectList
selectOne:是用来接收一条结果集
selectList:是用来接收多条结果集,一般是用结果来接收。
如果返回的数据不只一条,但是使用了selectOne来接收结果集,那么就会抛出异常
接收的参数可以换成对应的集合类型,selectOne换成selectList
参考地址
http://blog.csdn.net/you23hai45/article/details/51427403?locationNum=5&fps=1 http://blog.csdn.net/a4171175/article/details/78018143
相关文章推荐
- Caused by: 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 b
- org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned b
- Caused by: org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be
- mybatis中的一个异常:org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to
- TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 3
- org.apache.ibatis.exceptions.TooManyResultsException:
- org.apache.ibatis.exceptions.TooManyResultsException的异常排查过程
- Caused by: org.apache.ibatis.builder.BuilderException: The expression 'pd.nums' evaluated to a null
- Expected one result (or null) to be returned by selectOne(), but found
- mybatis报错:Expected one result (or null) to be returned by selectOne(), but found: 20
- 错误TooManyResultsException: 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
- 当Mybatis+sql遇到Expected one result (or null) to be returned by selectOne(), but found: 2时
- Expected one result (or null) to be returned by...
- mybatis报错:Expected one result (or null) to be returned by selectOne(), but found: 20
- 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: 3。。。。异常
- Expected one result (or null) to be returned by selectOne()
- Expected one result (or null) to be returned by selectOne(), but found: 20