Expected one result to be returned by selectOne,but found: 2
Posted 肖帆咪
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Expected one result to be returned by selectOne,but found: 2相关的知识,希望对你有一定的参考价值。
类型 异常报告
TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
消息 Request processing failed; nested exception is
org.mybatis.spring.MyBatisSystemException: nested exception is
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to
be returned by selectOne(), but found: 2
描述
服务器遇到一个意外的情况,阻止它完成请求。
例外情况
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned by selectOne(), but found: 2
因为查询到两条数据
原来的查询语句
解决方法
添加查询的用户的id,会自动将多条数据的同一用户封装到一个对象中
将id查询出来并映射到对象中
以上是关于Expected one result to be returned by selectOne,but found: 2的主要内容,如果未能解决你的问题,请参考以下文章
Expected one result (or null) to be returned by selectOne(), but found: 2
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 isFloatingType(grads[i].type().scalarType()) to be true, but got false.