锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产精品久久久久久久久久三级,亚洲视频专区在线,国产传媒一区http://www.aygfsteel.com/keer2345/category/35775.htmlJavazh-cnThu, 06 Nov 2008 01:14:20 GMTThu, 06 Nov 2008 01:14:20 GMT60HibernateUtil.javahttp://www.aygfsteel.com/keer2345/articles/238941.htmlkeerkeerThu, 06 Nov 2008 00:07:00 GMThttp://www.aygfsteel.com/keer2345/articles/238941.htmlhttp://www.aygfsteel.com/keer2345/comments/238941.htmlhttp://www.aygfsteel.com/keer2345/articles/238941.html#Feedback0http://www.aygfsteel.com/keer2345/comments/commentRss/238941.htmlhttp://www.aygfsteel.com/keer2345/services/trackbacks/238941.html
package com.keer.hibernate;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class HibernateUtil {
    
    
private static final SessionFactory sessionFactory;
    
    
static {
        
try {
            Configuration cfg 
= new Configuration().configure();
            sessionFactory 
= cfg.buildSessionFactory();
        } 
catch(Throwable e) {
            System.err.println(
"Initial SessionFactory creation failed" + e );
            
throw new ExceptionInInitializerError(e);
        }
    }
    
    
public static SessionFactory getSessionFactory() {
        
return sessionFactory;
    }
    
    
public static Session getSession() {
        
return sessionFactory.openSession();
    }
    
    
public static void closeSession(Session session) throws HibernateException {
        
if(session != null) {
            
if(session.isOpen()) {
                session.close();
            }
        }
    }
    
    
public static void rollback( Transaction tran ) {
        
try {
            
if(tran != null) {
                tran.rollback();
            } 
        } 
catch (HibernateException he) {
            System.out.println(
"Rollback faild." + he);
        }
    }   
}






keer 2008-11-06 08:07 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 清徐县| 宝丰县| 丹寨县| 华安县| 鸡西市| 唐海县| 天柱县| 彩票| 通州区| 华安县| 绥芬河市| 罗甸县| 万山特区| 丰镇市| 霍邱县| 准格尔旗| 铁岭县| 奈曼旗| 海口市| 垫江县| 独山县| 齐齐哈尔市| 乐业县| 河北省| 漾濞| 绥化市| 闵行区| 湘阴县| 克山县| 祥云县| 漾濞| 怀远县| 桃江县| 庄浪县| 集安市| 五常市| 新余市| 全椒县| 苏州市| 闵行区| 旅游|