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

day14:hibernate简单增删改查demo

时间:2016-09-29 01:25:47      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:

          Configuration cfg = new  Configuration().configure();

    SessionFactory  sf = cfg.buildSessionFactory();

         Session session = sf.openSession();

         session.beginTransaction();

    session.save();

         session.getTransaction().commit();

         session.close();

         sf.close();

 

 

       Configuration  cfg = new  Configuration().configure();

       SessionFactory  sf = cfg.buildSessionFactory();

       Session  session = sf.openSession();

       session.beginTransaction();

       session.update();

       session.getTransaction().commit();

       session.close();

       sf.close();

      

 

 

 

       Configuration  cfg = new  Configuration().configure();

   SessionFactory  sf = cfg.openSessionFactory();

       Session  session = sf.openSession();

       session.beginTransaction();

       session.delete();

       session.getTransaction().commit();

       session.close();

       sf.close();

 

 

       Configuration  cfg = Configuration().configure();

    SessionFactory  sf = cfg.openSessionFactory();

   Session  session = sf.openSession();

       session.findById();

       session.close();

       sf.close();

 

       手打了4遍hibernate执行代码块呀,哈哈方法很Low,加深印象吧

day14:hibernate简单增删改查demo

标签:

原文地址:http://www.cnblogs.com/ddouble4j/p/5917563.html

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