标签:
报此错误 :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