我正在编写一种方法来检索订单总和(order.total)高于和低于输入值的客户。
Criteria criteria = DetachedCriteria.forClass(Clients.class, "cl");
if (clOrdsTtlPrcFrom != -1 && clOrdsTtlPrcTo != -1) {
String sql = "select OwnerID from Orders group by OwnerID having sum(Total) >= :clOrdsTtlPrcFrom and sum(Total) <= :clOrdsTtlPrcTo";
SQLQuery query = sess.createSQLQuery(sql).addScalar("OwnerID", LongType.INSTANCE);
query.setParameter("clOrdsTtlPrcFrom", clOrdsTtlPrcFrom);
query.setParameter("clOrdsTtlPrcTo", clOrdsTtlPrcTo);
criteria.add(Restrictions.in("id", query.list()));
}
Criteria criteria2 = sess.createCriteria(Clients.class);
criteria2.add(Subqueries.propertyIn("id", criteria));
List<Clients> clients = (List<Clients>) criteria2.list();
一切都好,但是,有时我会收到一个错误:
java.sql.SQLException: Prepared or callable statement has more than 2000 parameter markers.
我怎样才能纠正这个方法,或者,也许,把它转换成完整的标准风格?