2010-06-29 92 views
2

我正在尝试构建JSF应用程序,并使用hibernate作为ORM解决方案。问题是我得到我的代码完整的复制代码春天可以添加到冬眠?

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

    tx.commit();} 

catch(Exception){} 

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

回答

3

是的,这正是Spring可以为你做的一件事情。

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

+0

我还有什么可以在ORM领域? – 2010-06-29 22:18:45

+0

它在13.1节列出:http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/orm.html – 2010-06-30 06:35:19