首页 > 代码库 > Hibernate4.3.x中SessionFactory的获取方法

Hibernate4.3.x中SessionFactory的获取方法

package cn.com.xf; import org.hibernate.SessionFactory;import org.hibernate.boot.registry.StandardServiceRegistryBuilder;import org.hibernate.cfg.Configuration;import org.hibernate.service.ServiceRegistry; public class HibernateUtils { private static SessionFactory sessionFactory;private static ServiceRegistry serviceRegistry; public static SessionFactory createSessionFactory() {    Configuration configuration = new Configuration().configure();    serviceRegistry = new StandardServiceRegistryBuilder().applySettings(            configuration.getProperties()).build();    sessionFactory = configuration.buildSessionFactory(serviceRegistry);    return sessionFactory;}}

Hibernate4.3.x中SessionFactory的获取方法