說明兩種獲取Session對象的方法會自動關閉可以用這個例子不是更好點
session=sessionFactory.getCurrentSession();Stundents stu=new Stundents(1, "老張", "男", new Date(), "武當山上");Stundents st=new Stundents(2, "l3l", "男", new Date(), "武當山上");session.save(stu);session.save(st);
session=sessionFactory.openSession();Stundents stu=new Stundents(1, "老張", "男", new Date(), "武當山上");Stundents st=new Stundents(2, "l3l", "男", new Date(), "武當山上");session.save(stu);session.save(st);
2016-07-03
transaction.commit();
? ? if(!session.isOpen())
? ? ?{
? ? ? ? System.out.println("getCurrentSession is close");
? ? ? ?
? ? ?}
2015-12-25
有什么區(qū)別?