You could try something like:
Code:
// session is your hibernate Session
String hql = "here is your HQL query";
SessionFactoryImplementor sfi = (SessionFactoryImplementor) session.getSessionFactory();
//build a map of filters from SessionFactory
//you could use (Map)null instead of this if you don't use filters
Map<String, Filter> mf = new HashMap<String, Filter>();
Set<String> filterNames = sfi.getDefinedFilterNames();
for(String filterName : filterNames) {
mf.put(filterName, session.getEnabledFilter(filterName));
}
QueryTranslator qt = sfi.getSettings().getQueryTranslatorFactory().createQueryTranslator(hql, hql, mf, sfi);
qt.compile((Map)null, false);
System.out.print("\n\n" + qt.getSQLString() + "\n\n");