当前位置: 代码迷 >> Java Web开发 >> 有关hibernate的初级有关问题
  详细解决方案

有关hibernate的初级有关问题

热度:176   发布时间:2016-04-16 21:43:18.0
有关hibernate的初级问题
在hibernate.org读文档
里面最新版本的hibernate已经与参考书不配套了……
其中sessionfactory的方法有些不懂
引用
 private static final SessionFactory sessionFactory = buildSessionFactory();

    private static SessionFactory buildSessionFactory() {
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            new Configuration().configure().buildSessionFactory(
    new StandardServiceRegistryBuilder().build() );
        }
        catch (Throwable ex) {
            // Make sure you log the exception, as it might be swallowed
            System.err.println("Initial SessionFactory creation failed." + ex);
            throw new ExceptionInInitializerError(ex);
        }
    }

    public static SessionFactory getSessionFactory() {
        return sessionFactory;
    }

主要是没有返回值不理解,看文档好像也不是省略了 还是说这样写也没有任何问题?
------解决思路----------------------
一般都不用这个方法buildSessionFactory();
------解决思路----------------------
private static SessionFactory buildSessionFactory(){}


   看这方法、就应该 有    返回值 、 

 你的这个 服务注册 有问题、
  相关解决方案