当前位置:首页 > 数据库 > 正文

hql 转 sql

import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.hql.ast.QueryTranslatorImpl;

QueryTranslatorImpl translator = new QueryTranslatorImpl("queryIdentifier", hql, 
    Collections.EMPTY_MAP, (SessionFactoryImplementor) getSessionFactory());
translator.compile(Collections.EMPTY_MAP, false);

translator.getSQLString();