解决 org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected
1, actual 0 的方法
1.捕捉这个异常然后返回null即可
String sql = "select * from gmm_model t where t.person_id = '"+personId+"' and t.person_type = '"+personType+"' and t.voice_seq = '"+voiceSeq+"'";
try {
Map<String, Object> map = PersistentFactory.getJdbcDao().queryForMap(sql);
catch (DataAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
2. 更换查询方法
由queryForMap() 改成 queryFoList()
处理Spring空结果异常

本文介绍了解决Spring框架中org.springframework.dao.EmptyResultDataAccessException异常的方法,包括通过捕获异常返回null以及更改查询方式从queryForMap到queryForList。
328

被折叠的 条评论
为什么被折叠?



