Expected one result (or null) to be returned by selectOne(), but found: 2
2017-05-23 08:40
701 查看
看到标题就已经很明了了:
两种情况:
1.你想查询一条数据,但返回两条数据:
2.你想查询多条数据,但是前台限制只能查询一条
(1) 检查自己的数据sql语句写对没有(关于mybaties的sql操作自己百度)
(2) 查看mybaties的返回值(resultType或resultMap),可以返回list,map等数据
(3) dao层接口要与mybaties中返回值和接收值都要保持一致
例:返回map数据
返回多条数据是多个Map,多个Map放在List中用List<Map<String,String>>接收返回数据
Mybatis返回的Map是这样的一种格式:Map<字段名称,字段值>
一个Map<字段名,字段值>对象代表一行数据
两种情况:
1.你想查询一条数据,但返回两条数据:
2.你想查询多条数据,但是前台限制只能查询一条
(1) 检查自己的数据sql语句写对没有(关于mybaties的sql操作自己百度)
(2) 查看mybaties的返回值(resultType或resultMap),可以返回list,map等数据
(3) dao层接口要与mybaties中返回值和接收值都要保持一致
例:返回map数据
返回多条数据是多个Map,多个Map放在List中用List<Map<String,String>>接收返回数据
Mybatis返回的Map是这样的一种格式:Map<字段名称,字段值>
一个Map<字段名,字段值>对象代表一行数据
相关文章推荐
- 当Mybatis+sql遇到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
- 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: 4
- 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: 3
- 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
- Caused by: org.apache.ibatis.exceptions.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问题完美解决
- 错误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报错: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: XX
- 遇到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(), but found: 2
- one result (or null) to be returned by selectOne(), but found
- Expected one result (or null) to be returned by selectOne()