added utility to return CriteriaImpl from DetachedQuery or Query