Hibernate version:3.1
For my project I need to display the generated SQL on the webpage. I was wondering how I could retrieve the generated SQL from an HQL query or from a save or delete.
I tried using this code
Code:
QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
SessionFactoryImplementor factory = (SessionFactoryImplementor)getHibernateTemplate().getSessionFactory();
QueryTranslator newQueryTranslator = ast.createQueryTranslator( hql, hql, Collections.EMPTY_MAP, factory );
newQueryTranslator.compile( replacements, false );
String sql = newQueryTranslator.getSQLString();
It seems to work except when I have parameters. Then it just displays ?. I have set show_sql to true and get the same thing. Any help is appreciated.
Peter