title: HibernateTemplate vs HibernateDaoSupport vs SessionFactory Injection
body: <p>I have seen in lot of forums and still in confusion. We are starting a new project with Spring 3.1 &amp; Hibernate 4 and need to decide which strategy to use for Hibernate with Spring:</p>
  
  <ol>
  <li><p>Accessing Hibernate directly</p>
  
  <p>Session session = HibernateUtil.getSessionFactory().getCurrentSession();
      session.beginTransaction();</p></li>
  <li><p>Using HibernateTemplate</p>
  
  <p>List bb = (List)hibernateTemplate.find("from Entity");</p></li>
  <li><p>Using HibernateDAOSupport classes </p>
  
  <p>List bb =(List)getHibernateTemplate().find("from Entity");</p></li>
  </ol>
  
  <p>Can you please help what should i use? I have read from <a href="http://www.coderanch.com/t/501712/Spring/HibernateTemplate-or-HibernateDaoSupport-or-Hibernate" rel="nofollow">CodeRanch</a> and one another <a href="http://www.coderanch.com/t/479938/ORM/databases/Diff-between-Hinernate-Template-HibernateDAOSupport" rel="nofollow">link</a> which tell that from <strong>Hibernate 3.x</strong> onwards we should inject <code>SessionFactory</code> in our DAO Classes(using <code>@Repository</code>). </p>
  
  <p>Can someone explain this in detail?</p>
  
  <p>Regards,</p>
  
  <p>Arun Kumar</p>