什么可以弹簧加入休眠?

时间:2010-06-29 21:02:06

标签: hibernate spring

我正在尝试构建JSF应用程序,我正在使用hibernate作为ORM解决方案。问题是我的代码充满了复制代码

Transaction tx = null;
Session session = SessionFactoryUtil.getInstance().getCurrentSession();
try {
  tx = session.beginTransaction();

  tx.commit();}

catch(Exception){}

在每个功能中。春天能帮助我避免这种情况吗?或者它可以添加什么,因为我发现hibernate充满了功能?

1 个答案:

答案 0 :(得分:3)

是的,这正是Spring可以为您做的事情之一。

查看参考手册中的chapter on transaction management