StandardServiceRegistryBuilder

org.hibernate.boot.registry.StandardServiceRegistryBuilder
hibernate4.3

Configuration cfg = new Configuration()
        .configure();

        ServiceRegistry serviceRegistry = new ServiceRegistryBuilder()
                      .applySettings(cfg.getProperties())
                      .buildServiceRegistry();
        
        /*ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder()
                      .applySettings(cfg.getProperties()).build();*/

        SessionFactory sessionFactory = cfg.buildSessionFactory(serviceRegistry);

        Session session = sessionFactory.openSession();
        Transaction tx = session.beginTransaction();

 

posted @ 2016-08-09 16:16  JillWen  阅读(2649)  评论(2编辑  收藏  举报