HibernateDaoSupport

本文详细介绍了Spring框架中的HibernateDaoSupport类如何简化Hibernate-based数据访问对象的开发过程,通过继承该类,开发者可以轻松实现数据操作,并且能够利用HibernateTemplate进行高效的数据交互。此外,文章还探讨了SessionFactory的设置与使用,以及如何通过自定义HibernateTemplate实例来灵活配置会话工厂。此教程旨在为开发者提供一个高效、便捷的ORM解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


Spring 的 Hibernate ORM 框架带来了方便的 HibernateDaoSupport 类,你的 DAO类可以继承它:
public class StudentDaoHibernate extends HibernateDaoSupport implements StudentDao{
.................
}


org.springframework.orm.hibernate4.support

类 HibernateDaoSupport

  • java.lang.Object
    • DaoSupport
      • org.springframework.orm.hibernate4.support.HibernateDaoSupport


  • public abstract class HibernateDaoSupport
    extends DaoSupport
    Convenient super class for Hibernate-based data access objects.

    Requires a org.hibernate.SessionFactory to be set, providing a HibernateTemplate based on it to subclasses through the getHibernateTemplate() method. Can alternatively be initialized directly with a HibernateTemplate, in order to reuse the latter's settings such as the SessionFactory, exception translator, flush mode, etc.

    This class will create its own HibernateTemplate instance if a SessionFactory is passed in. The "allowCreate" flag on that HibernateTemplate will be "true" by default. A custom HibernateTemplate instance can be used through overriding createHibernateTemplate(SessionFactory).

    NOTE: Hibernate access code can also be coded in plain Hibernate style. Hence, for newly started projects, consider adopting the standard Hibernate style of coding data access objects instead, based on org.hibernate.SessionFactory#getCurrentSession(). This HibernateTemplate primarily exists as a migration helper for Hibernate 3 based data access code, to benefit from bug fixes in Hibernate 4.x.

    从以下版本开始:
    4.0.1
    另请参阅:
    setSessionFactory(SessionFactory), getHibernateTemplate(), HibernateTemplate


转载自: 这里那里
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值