-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to convert HQL to SQL
PostPosted: Fri Mar 18, 2005 12:37 pm 
Newbie

Joined: Thu Mar 03, 2005 2:26 pm
Posts: 4
Hi,

Is there a way in Hibernate 3.0 to convert HQL to SQL? We have a search framework that constructs HQL. However we need to add additional sub-query(which is a native sql) in the sql that is generated from that HQL. Is there a way we can get generated sql from HQL?

Thanks,
Jian


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 16, 2005 7:45 pm 
Regular
Regular

Joined: Mon Sep 20, 2004 8:42 am
Posts: 58
Location: Boston, US
I am interested in this as well.

Is there an API that given HQL/Hibernate Query object returns the underlying SQL string?

Thanks,
Sanjiv


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 16, 2005 10:38 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
This is example (see hibernate test) :
Code:
Map replacements = null;
        boolean scalar=false;
        String query = "select ..";
    QueryTranslator newQueryTranslator;
    QueryTranslatorFactory ast = new ASTQueryTranslatorFactory();
    String hql = query;
    SessionFactoryImplementor factory = getSessionFactoryImplementor();
    newQueryTranslator = ast.createQueryTranslator( hql, Collections.EMPTY_MAP, factory );
    newQueryTranslator.compile( replacements, scalar );
    String sql = newQueryTranslator.getSQLString();


regards


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