日期:2014-05-20 浏览次数:21048 次
QueryTranslatorImpl queryTranslator = new QueryTranslatorImpl( hql, hql, Collections.EMPTY_MAP, (SessionFactoryImplementor) session .getSessionFactory()); queryTranslator.compile(Collections.EMPTY_MAP, false); String tempSQL = queryTranslator.getSQLString(); System.out.println(tempSQL); // 将对应转换完成的SQL语句 套入查询模版 String countSQL = "select count(*) from (" + tempSQL + ") tmp_count_t"; // 创建Query 对象 System.out.println(countSQL); Query query = session.createSQLQuery(countSQL);