-->
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.  [ 5 posts ] 
Author Message
 Post subject: Translating HQL to SQL
PostPosted: Mon Feb 07, 2005 8:24 am 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
I need to have the string of SQL that Hibernate is going to execute for a SELECT, starting from a HQL string.
I mean a method like session.find(HQLQuery) which returns the SQL query.
This because I need to perform a INSERT INTO table_name SELECT ...
I I whould like to use Hibernate for the last part of the statement
Any help will be appreciated.
Regards
Alessandro Rizzi


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 5:50 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
see org.hibernate.MappingException.QueryTranslatorTestCase#assertTranslation in
hibernate3 source tree

regards


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 6:15 am 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
snpesnpe wrote:
see org.hibernate.MappingException.QueryTranslatorTestCase#assertTranslation in
hibernate3 source tree

regards


Is there anything in Hibernate 2.1?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 6:59 am 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
see method runClassicTranslator in same java

regards


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 7:30 am 
Regular
Regular

Joined: Thu Sep 04, 2003 10:43 am
Posts: 61
snpesnpe wrote:
see method runClassicTranslator in same java

Found it, this is my method:
public static String translateHQL2SQL(SessionFactory sf, String HQL) throws HibernateException {
QueryTranslator qt = new QueryTranslator(HQL);
qt.compile(( SessionFactoryImplementor ) sf, new HashMap(), false );
return(qt.getSQLString());
}


Many many thanks for you help.
Regards
Alessandro Rizzi
regards


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.