public DataTableReturn getDataTableReturn(final CriteriaQuery cq,
final boolean isOffset) {
Criteria criteria = cq.getDetachedCriteria().getExecutableCriteria(
getSession());
CriteriaImpl impl = (CriteriaImpl) criteria;
// 先把Projection和OrderBy条件取出来,清空两者来执行Count操作
Projection projection = impl.getProjection();
final int allCounts = ((Long) criteria.setProjection(
Projections.rowCount()).uniqueResult()).intValue();
criteria.setProjection(projection);
if (projection == null) {
criteria.setResultTransformer(CriteriaSpecification.ROOT_ENTITY);