For existing DetachedCriteria, how to get the row count of its query results?
If we use projection like:
DetachedCriteria existCriteria = ... existCriteria.setProjection(Projections.rowCount());
It will override existing projections(such as group by, if any), and row count will not be correct.
I hope to have a new criteria wrapping over existing one and add rowCount projection to the new one.
DetachedCriteria newCriteria = new DetachedCriteria(existCriteria) newCriteria.setProjection(Projections.rowCount());
But current Hibernate does not support this. Is there any workaround?
Thanks! Dave
|