spring DAO hibernate ORM

Posted on 2011-05-06
Last Modified: 2012-05-11

I was reading folowing lines. And I did not understand clearly.

Spring’s Hibernate ORM framework also comes with the convenience class HibernateDaoSupport
that your DAO classes can subclass:
public class StudentDaoHibernate extends HibernateDaoSupport
implements StudentDao {

If you opt for this design, you need to wire in a SessionFactory—the Hibernate-
DaoSupport class comes with this property. This class provides you with a convenience
method, getHibernateTemplate(), to easily get an instance of a HibernateTemplate.
It also has a getSession() and a closeSessionIfNecessary() method if, for some
reason, you need to perform a Hibernate operation without using a Hibernate-
Template. We are sure you will find these cases will be the exception (no pun
intended). So now you can see how easily you can integrate an ORM tool like

Any ideas, resources,sample code,links, highly appreciated. thanks in advance.
Question by:gudii9
    LVL 92

    Expert Comment

    The HibernateDaoSupport provides  utility methods for make hibernate calls making it a lot simpler for you. To do this it requires a SessionFactory to access the dabaase, so you need to supply this to your dao when you initialise it
    LVL 7

    Author Comment

    >>need to wire in a SessionFactory—the Hibernate-
    DaoSupport class comes with this property.
    how do we wire SessionFactory property inside Hibernate-
    DaoSupport class in the spring application. please advise
    LVL 92

    Accepted Solution

    <bean id="myDao" class="">
      <property name="sessionFactory">
        <ref bean="sessionFactory"/>

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    MaxSpan challenge 9 50
    wordsWithoutList  challenge 24 61
    How Complex Is This Java Course ? 9 51
    wordappend challenge 8 47
    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now