当我在postgesql上通过sql直接执行语句时,它可以工作。
使用java服务/ hibernate时,它会返回错误“查询返回多个ResultSet。”
在eclipse中为hibernate设置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;
}