现在的位置: 首页 > 综合 > 正文

HibernateDaoSupport

2019年05月12日 ⁄ 综合 ⁄ 共 1384字 ⁄ 字号 评论关闭
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

转载自:这里那里

抱歉!评论已关闭.