如何在DAO层既使用注解又使用HibernateDaoSupport

如题所述

第1个回答  2017-02-09
HibernateDaoSupport类是Spring为Hibernate的DAO提供的工具类。该类主要提供如下两个方法,方便DAO的实现:
1、public final HibernateTemplate getHibernateTemplate()
2、public final void setSessionFactory(SessionFactory sessionFactory)
其中,setSessionFactory方法用来接收Spring的ApplicationContext的依赖注入,可接收配置在Spring的SessionFactory实例,getHibernateTemplate方法则用来根据刚才的SessionFactory产生Session,最后生成HibernateTemplate来完成数据库的访问。本回答被提问者采纳
第2个回答  2018-08-03
HibernateDaoSupport类是Spring为Hibernate的DAO提供的工具类。该类主要提供如下两个方法,方便DAO的实现:
1、public final HibernateTemplate getHibernateTemplate()
2、public final void setSessionFactory(SessionFactory sessionFactory)
其中,setSessionFactory方法用来接收Spring的ApplicationContext的依赖注入,可接收配置在Spring的SessionFactory实例,getHibernateTemplate方法则用来根据刚才的SessionFactory产生Session,最后生成HibernateTemplate来完成数据库的访问。本回答被网友采纳
相似回答