public class HibernateUtil { 
    private static final ThreadLocal<Session> threadLocal = new ThreadLocal<Session>(); 
    private static SessionFactory sessionFactory = null; 
    private static Session session; 
    private static Transaction transaction; 
    static { 
        try { 
            Configuration cfg = new Configuration().configure(); 
            ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(cfg.getProperties()).build(); 
            sessionFactory = cfg.buildSessionFactory(serviceRegistry); 
            session=sessionFactory.openSession(); 
            transaction=session.beginTransaction(); 
        } catch (Exception e) { 
            System.out.print("创建会话工厂失败"); 
        } 
    }
ansaction() ;
发布评论

分享到:

IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

HBase核心知识点总结详解
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。