码迷,mamicode.com
首页 > 系统相关 > 详细

HibernateUitl

时间:2014-09-19 16:56:35      阅读:294      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   io   div   sp   log   on   c   

 

 

 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

标签:style   blog   color   io   div   sp   log   on   c   

原文地址:http://www.cnblogs.com/thrive/p/3981540.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!