我正在尝试构建 JSF 应用程序,并使用 hibernate 作为 ORM 解决方案。问题是我的代码充满了重复代码
Transaction tx = null;
Session session = SessionFactoryUtil.getInstance().getCurrentSession();
try {
tx = session.beginTransaction();
tx.commit();}
catch(Exception){}
在每个函数中。 Spring 可以帮助我避免这种情况吗?或者它可以添加什么,因为我发现 hibernate 充满了功能?
最佳答案
是的,这正是 Spring 可以为您做的事情之一。
查看 chapter on transaction management在引用手册中。
关于hibernate - spring 可以为 hibernate 添加什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3144697/