Spring 3.1 + Hibernate 4 - HibernateTemplate [英] Spring 3.1 + Hibernate 4 - HibernateTemplate

查看:92
本文介绍了Spring 3.1 + Hibernate 4 - HibernateTemplate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring的 hibernate4包

a>似乎已经取消了HibernateTemplate和HibernateDaoSupport。在我的Spring应用程序中,我正在将Hibernate从3升级到4,我拥有Spring的HibernateDaoSupport的几个子类以及通过HibernateTemplate的一些Hibernate回调。也许我没有使用正确的搜索条件,但是我无法在参考文档中找到关于如何将这些重构为使用参考指南中所述的普通的hibernate daos。任何人都可以帮助我指出正确的方向吗? HibernateTemplate的javadoc 解释它。您应该使用 sessionFactory.getCurrentSession()来获得会话,并直接使用本地Hibernate Session API。


Spring's hibernate4 package appears to have done away with HibernateTemplate and HibernateDaoSupport. I'm in the process of upgrading Hibernate from 3 to 4 in my Spring app and I have a fair few subclasses of Spring's HibernateDaoSupport and a couple of Hibernate callbacks through HibernateTemplate. Perhaps I'm not using the right search terms, but I can't find any info in the reference docs on how I should be refactoring these to "use plain hibernate daos as explained in the reference guide". Can anyone help point me in the right direction?

解决方案

The javadoc of HibernateTemplate explains it. You should use sessionFactory.getCurrentSession() to get a session, and use the native Hibernate Session API directly.

这篇关于Spring 3.1 + Hibernate 4 - HibernateTemplate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆