标签:class apply xml文件 ber cer blog 方法 registry XML
hibernate3.X构造SessionFactory方法
//读取hibernate.cfg.xml文件 Configuration cfg = new Configuration().configure(); //建立SessionFactory SessionFactory factory = cfg.buildSessionFactory();
在hibernate4.3中函数buildSessionFactory()已经作废,以下是新的构造方法
private static ServiceRegistry serviceRegistry = null; private static Configuration cfg = null; private static SessionFactory sessionFactory = null; cfg = new Configuration().configure(); serviceRegistry = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build(); sessionFactory = cfg.buildSessionFactory(serviceRegistry); //取得session Session session = null; //开启session session = sessionFactory.openSession();
hibernate4.3版本构造SessionFactory方法
标签:class apply xml文件 ber cer blog 方法 registry XML
原文地址:http://www.cnblogs.com/heirenly/p/6338133.html