Issue Type: Improvement Improvement
Affects Versions: 4.1.5.SP1, 3.6.10
Assignee: Unassigned
Components: query-criteria
Created: 22/Jul/12 10:13 PM
Description:

let developer can reuse DetachedCriteria perform a pre-counting before the actual query.
most of databases cannot execute aggregate function with order clause,so the order entries must remove when counting.

CriteriaImpl impl = detachedCriteria.getCriteriaImpl();
// remove order
List<OrderEntry> orderEntries = new ArrayList<OrderEntry>();
Iterator<OrderEntry> it = impl.iterateOrderings();
while (it.hasNext()) { orderEntries.add(it.next()); it.remove(); }
// pre-counting
long totalRecord = countByCriteria(detachedCriteria);
// restore order
for (OrderEntry oe : orderEntries)
impl.addOrder(oe.getOrder());
// actual query
List results = findListByCriteria(detachedCriteria);

Project: Hibernate ORM
Priority: Major Major
Reporter: zhouyanming
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira