首页 > Web开发 > 详细

day14:hibernate简单增删改查demo

时间:2016-09-29 01:23:55      阅读:192      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!