真正的优点是:
- 轻量级声明性语法。相比:
public void saveEmployee(Employee e) { Session s = sf.getCurrentSession(); s.getTransaction().begin(); s.save(e); s.getTransaction().commit(); }
和
@Transactional public void saveEmployee(Employee e) { sf.getCurrentSession().save(e); }
@Transactional public void hireEmployee(Employee e) { dao.saveEmployee(e); doOtherStuffInTheSameTransaction(e); }
- 发生异常时自动回滚
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)