Triple King

好记性不如烂笔头,曾经学习到的东西都是一笔财富,有空时不妨记录下来。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Hibernate3中将指定的HQL语句转换成SQL语句

Posted on 2013-07-31 10:55  TripleKing  阅读(2705)  评论(0)    收藏  举报
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.hql.ast.QueryTranslatorImpl;

QueryTranslatorImpl queryTranslator=new QueryTranslatorImpl(hql,hql,Collections.EMPTY_MAP,(SessionFactoryImplementor)getSessionFactory());
queryTranslator.compile(Collections.EMPTY_MAP, false);

queryTranslator.getSQLString();