HibernateUitl

时间:2014-09-19 16:56:35   收藏:0   阅读:294

 

 

 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 }

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!