Problem solved. 
It was a problem with the Query Translator. The job of the Query Translator is to turn HQL queries into SQL queries. The 
ClassicQueryTranslatorFactory is the version that was included in Hibernate 2. In Hibernate 3 they created a new Query Translator, the 
ASTQueryTranslatorFactory. 
ClassicQueryTranslatorFactory does not know about WITH clause.
Set the Query Translator in the hibernate.properties file:
Code:
#hibernate.query.factory_class org.hibernate.hql.classic.ClassicQueryTranslatorFactory
hibernate.query.factory_class org.hibernate.hql.ast.ASTQueryTranslatorFactory