码迷,mamicode.com
首页 > Web开发 > 详细

封装hibernate

时间:2017-04-15 13:54:11      阅读:189      评论:0      收藏:0      [点我收藏+]

标签:builds   new   config   ber   app   ack   void   hibernate   ret   

private static SessionFactory sf;
static{
Configuration cfg=new Configuration().configure();
ServiceRegistry sr=new ServiceRegistryBuilder()
.applySettings(cfg.getProperties())
.buildServiceRegistry();
sf=cfg.buildSessionFactory(sr);
}
public static Session getCurrentSession(){
return sf.getCurrentSession();
}
public static void beginTransaction(){
getCurrentSession().beginTransaction();
}
public static void commit(){
getCurrentSession().getTransaction().commit();
}
public static void rollback(){
getCurrentSession().getTransaction().rollback();
}

封装hibernate

标签:builds   new   config   ber   app   ack   void   hibernate   ret   

原文地址:http://www.cnblogs.com/dawn-and-night/p/6713739.html

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