delete update在hibernate中的使用

之前在hibernate中使用了save方法,使用getCurrentSession不需要自己管理事务,很方便.

sessionFactory.getCurrentSession().save(applicationInfo);

同事update和delete也有两种类似方法:

Session session = sessionFactory.getCurrentSession();
session.update(applicationInfo);
session.flush();
Session session = sessionFactory.openSession();
session.beginTransaction();
session.update(applicationInfo);
session.getTransaction().commit();

使用getCurrentSession和openSession的具体实现存在差异.

原文地址:https://www.cnblogs.com/sosayweall/p/5923065.html