import java.util.Collections;
import org.hibernate.SessionFactory;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.hql.internal.ast.QueryTranslatorImpl;
public class HQLUtils{
public String hqlToSql(SessionFactory sessionFactory,String hql){
QueryTranslatorImpl queryTranslator=new QueryTranslatorImpl(hql,hql,Collections.EMPTY_MAP,(SessionFactoryImplementor)sessionFactory);
queryTranslator.compile(Collections.EMPTY_MAP, false);
return queryTranslator.getSQLString();
}
}
转载于:https://my.oschina.net/banbang/blog/478973