Java 类org.hibernate.loader.OuterJoinLoader 实例源码

项目:hibernate-filter    文件:TableFilter.java   
public static String showSql(Criteria criteria){
    try {
        CriteriaImpl c = (CriteriaImpl) criteria;
        SessionImpl s = (SessionImpl) c.getSession();
        SessionFactoryImplementor factory = (SessionFactoryImplementor) s.getSessionFactory();
        String[] implementors = factory.getImplementors(c.getEntityOrClassName());
        LoadQueryInfluencers lqis = new LoadQueryInfluencers();
        CriteriaLoader loader = new CriteriaLoader((OuterJoinLoadable) factory.getEntityPersister(implementors[0]), factory, c, implementors[0], lqis);
        Field f = OuterJoinLoader.class.getDeclaredField("sql");
        f.setAccessible(true);
        return (String) f.get(loader);
    }catch (Exception e){
        e.printStackTrace();
        return "";
    }
}