-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: How do I programatically convert HQL to SQL?
PostPosted: Tue Jun 13, 2006 9:11 am 
Newbie

Joined: Thu Sep 02, 2004 10:02 pm
Posts: 3
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


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 13, 2006 9:15 am 
Newbie

Joined: Wed Feb 08, 2006 3:57 pm
Posts: 16
May be logging driver can help you?[/url]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.