hibernate support sessionFactory 注入
来源:互联网 发布:消除红眼软件 编辑:程序博客网 时间:2024/05/21 07:06
今天尝试了一下使用Annotation整合Spring2.5和Hibernate3.3,在使用HibernateDaoSupport的时候才想起Annotation必须是加在源码上,但是setSessionFactory被标记为final,那继承HibernateDaoSupport后就不能重写setSessionFactory方法来实现使用Annotation的注入。代码段如下:
1: /**
2: * Set the Hibernate SessionFactory to be used by this DAO.
3: * Will automatically create a HibernateTemplate for the given SessionFactory.
4: * @see #createHibernateTemplate
5: * @see #setHibernateTemplate
6: */
7: public final void setSessionFactory(SessionFactory sessionFactory) {
8: if (this.hibernateTemplate == null || sessionFactory != this.hibernateTemplate.getSessionFactory()) {
9: this.hibernateTemplate = createHibernateTemplate(sessionFactory);
10: }
11: }
苦思冥想之际,想到一个可以暂时解决问题的办法。代码段如下:
1: @Resource(name="sessionFactory")
2: public void setBaseDaoSessionFactory(SessionFactory sessionFactory) {
3: super.setSessionFactory(sessionFactory);
4: }
在子类中添加一个新的方法来调用父类的setSessionFactory方法,然后把sessionFactory注入,OK!
- hibernate support sessionFactory 注入
- Struts+Spring+Hibernate处理Lob(Blob,Clob)-->sessionFactory中注入 org.springframework.jdbc.support.lob.Def
- Spring中注入Hibernate的SessionFactory
- spring 自动注入Hibernate中的SessionFactory 探索
- SessionFactory (org.hibernate.SessionFactory)
- Spring注入Hibernate的SessionFactory不分离配置文件
- spring整合Hibernate使用set方式注入sessionFactory问题
- hibernate SessionFactory
- Hibernate SessionFactory
- Hibernate SessionFactory
- hibernatesupportDao 注入 sessionfactory hibernateTemplate
- Spring注入SessionFactory问题
- HibernateDaoSupport注入sessionFactory
- 注解的方式注入org.hibernate.SessionFactory到自定义的Dao中
- 注解的方式注入org.hibernate.SessionFactory到自定义的Dao中
- Spring配置C3P0数据源,并注入到hibernate的sessionFactory中
- Spring与Hibernate整合中,使用OpenSessionInViewFilter后出现sessionFactory未注入问题
- Hibernate的Transaction SessionFactory
- Google 浏览器(2011)书签同步
- Eclipse 中安装 javascript aptana 插件
- 几种JAVA常见排序算法
- Jquery 常用代码。
- C# 制作 艺术字
- hibernate support sessionFactory 注入
- php安全
- 多功能编辑器的使用技巧(kindeditor)
- PDF文档安全技术
- IMAGE 的缩放
- 谷歌宣布Android 3.0暂停开源
- dblp数据源中的crossref标签
- 今天解决了QT Creator交叉编译提示make:arm-linux-g++:Command not found
- DNS域名压缩