码迷,mamicode.com
首页 > 数据库 > 详细

EmptyResultDataAccessException

时间:2016-07-11 17:07:17      阅读:350      评论:0      收藏:0      [点我收藏+]

标签:

报此错误 :org.springframework.dao.EmptyResultDataAccessException: Incorrect result size: expected 1, actual 0,

查询的结果集 为null,导致报错 

@Transactional(readOnly = true)
public Map<String, Object> findActivityTask(final Long productId){
return super.findBySQL(new SQLGenerator() {
@Override
public Map<String, Object[]> generate() {

Map<String, Object[]> result = Maps.newHashMap();
List<Object> list = new ArrayList<Object>();

StringBuffer sql = new StringBuffer();
sql.append(" SELECT d.id, d.criteria_tagline AS criteriaTagline FROM ex_product_base AS a ");
sql.append(" LEFT JOIN ex_activity_gift AS b ON a.id = b.product_id AND b.state = 0 ");
sql.append(" LEFT JOIN ex_activity_base AS c ON b.id = c.id AND c.state = 0 AND c.open_type = 2 ");
sql.append(" INNER JOIN ex_activity_task AS d ON c.id = d.activity_base_id AND d.state = 0 AND d.open_type = 2 WHERE 1=1 ");

if (productId != null) {
sql.append(" AND a.id = ? ");
list.add(productId);
}
sql.append(" ORDER BY c.create_date DESC LIMIT 1 ");

result.put(sql.toString(), list.toArray());
return result;
}
});
}

EmptyResultDataAccessException

标签:

原文地址:http://www.cnblogs.com/liduanwen/p/5660650.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!