I used nativ SQL from a Criteria in my last project to do aritmetic operations with Projections.sqlProjection().
With
CriteriaQueryTranslator it's also possible to access nativ SQL. I described this at
http://blog.bambo.it/2009/12/generic-subcriterias-for-hibernate.html and
http://blog.bambo.it/2009/12/arithmetic-operations-using-generic.html.
Code:
CriteriaImpl criteriaImpl = ( CriteriaImpl ) rootCriteria;
SessionImplementor session = ( ( CriteriaImpl ) rootCriteria ).getSession();
SessionFactoryImplementor factory = session.getFactory();
String[] implementors = factory.getImplementors( criteriaImpl.getEntityOrClassName() );
CriteriaQueryTranslator translator = new CriteriaQueryTranslator( factory,
( CriteriaImpl ) rootCriteria, implementors[ 0 ], CriteriaQueryTranslator.ROOT_SQL_ALIAS );