org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1,actual 0 1
2017-10-30 20:33
489 查看
org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1,actual 0 10
org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0请问是什么意思,如何解决????
xyh52040 | 浏览
16117 次 |举报
我有更好的答案
发布于2016-10-31 15:59
最佳答案
两种方案:
用queryForList方法替换queryForObject或者queryForMap,因为这两个方法必须要有值,不能为空。
把这个异常捕获,用try/catch,如下
向左转|向右转
本回答由网友推荐
举报| 答案纠错 | 评论
38 3
发布评论
雪飘时吻你 采纳率:54% 擅长: 河南 许昌市 驻马店市
其他回答
这个查询的结果是null,没有数据所以就提示acual 为0.而查询的时候是期望查询有结果有记录,并且记录数是1. spring 这个查询中没有查询到数据就报错。解决方案就是要查询有结果,或者换一种查询方式。热心网友| 发布于2015-12-15 14:24举报| 评论(1) 21 3发布评论
fangletian|2016-3-8
22:11
我想知道如果为空怎么处理!回复
相关文章推荐
- org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
- org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
- org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
- org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1,actual 0 1
- org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
- org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
- org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
- org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
- org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
- org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0
- 解决 org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected
- spring queryForObject 错误org.springframework.dao.EmptyResultDataAccessException: Incorrect result siz
- org.springframework.dao.EmptyResultDataAccessException
- org.springframework.dao.EmptyResultDataAccessException
- spring4报错Caused by: java.lang.NoClassDefFoundError: org/springframework/dao/DataAccessException
- The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly referenced
- [hibernate]:org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hi
- org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [41] did not match expected type [java.lang.Integer (n/a)];
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query;
- org/springframework/dao/DataAccessException