With Hibernate Criteria API the only way to view the SQL output is to run the query. No preview. In order to view the generated SQL you must configure your datasource to log your sql statements. Here is a persistence.xml example for Hibernate MS SQLServer dialect. The ="true" elements are all instructions to be verbose when running Hibernate queries. This has a big impact on performance, needless to say.
<persistence-unit name="projectPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/projectDS</jta-data-source>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.SQLServerDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.use_sql_comments" value="true" />
</properties>
</persistence-unit>
The sql will only be generated when you run criteria.list()
Criteria crit = session.createCriteria(Foo.class);
// create aliases and projections etc. whose effects are not visible yet
List<Foo> fooList = crit.list(); // only now can you see errors!
See Logging hibernate SQL using log4j