![](/img/trans.png)
[英]PostgreSQL & JDBC "Multiple ResultSets were returned by the query"
[英]SQL Query OK, but using Hibernate “Multiple ResultSets were returned by the query.”-Error
当我直接在postgesql上通过sql执行语句时,它可以工作。
使用Java服务/休眠时,它向我返回错误“查询返回了多个ResultSets”。
在eclipse中为休眠设置max.log不会显示更多详细信息。
有人有找到解决方案吗? 提前致谢。
public List<List<String>> getProductionGroupedByTime(
final Object[] policyTypes,
final Object[] policyStatuses,
final Object[] businessTypes,
final Object[] businessChannels,
final Object[] agents,
final Object[] agents2,
final Object[] roles,
final Object[] productDetails,
final Date beginDate,
final Date endDate) {
final long begin = System.currentTimeMillis();
final Session session = sessionFactory.getCurrentSession();
final StringBuffer sql = new StringBuffer();
sql.append("select ");
sql.append("cast(extract(year from coalesce(p.production_date,p.date_created)) as text) as year, ");
sql.append("cast(extract(month from coalesce(p.production_date,p.date_created)) as text) as month, ");
sql.append("cast(count(p.id) as text) as count, ");
if (ArrayUtils.isNotEmpty(productDetails)) {
sql.append("cast(sum(ipd.premium) as text) as prod, ");
} else {
sql.append("cast(sum(coalesce(p.manual_premium,p.premium)) as text) as prod, ");
}
sql.append("cast(round((sum(coalesce(p.manual_premium,p.premium)) / 100 ) + count(p.id), 2) as text) as points ");
sql.append("from policy p ");
sql.append(addJoinsAndWhereClause(policyTypes, policyStatuses, businessTypes, businessChannels, agents, agents2, roles, productDetails, beginDate, endDate));
sql.append("group by ");
sql.append("year, ");
sql.append("month ");
sql.append("having sum(coalesce(p.manual_premium,p.premium)) > 0 ");
sql.append("order by ");
sql.append("year asc, ");
sql.append("month asc; ");
logger.debug(sql);
SQLQuery query = session.createSQLQuery(sql.toString());
query = setQueryParameters(query, policyTypes, policyStatuses, businessTypes, businessChannels, agents, agents2, roles, productDetails, beginDate, endDate);
final List<List<String>> result = DiacUtils.listOfObjectArrayToListOfListOfString(query.list());
logger.debug((System.currentTimeMillis() - begin) + " ms");
return result;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.