首页 > 代码库 > HibernateUitl

HibernateUitl

 

 

 1 package com.cn; 2  3 import org.hibernate.Session; 4 import org.hibernate.SessionFactory; 5 import org.hibernate.cfg.Configuration; 6  7 public final class HibernateUitl { 8     private static SessionFactory sessionFactory; 9 10     private HibernateUitl() {11     }12 13     static {14         Configuration cfg = new Configuration();15         cfg.configure();16         sessionFactory = cfg.buildSessionFactory();17     }18 19     public static SessionFactory getSessionFactory() {20         return sessionFactory;21     }22 23     public static Session getSession() {24         return sessionFactory.openSession();25     }26 }

 

HibernateUitl