I have seen in lot of forums and still in confusion. We are starting a new project with Spring 3.1 & Hibernate 4 and need to decide which strategy to use for Hibernate with Spring:
Accessing Hibernate directly
Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction();
Using HibernateTemplate
List bb = (List)hibernateTemplate.find("from Entity");
Using HibernateDAOSupport classes
List bb =(List)getHibernateTemplate().find("from Entity");
Can you please help what should i use? I have read from CodeRanch and one another link which tell that from Hibernate 3.x onwards we should inject SessionFactory
in our DAO Classes(using @Repository
).
Can someone explain this in detail?
Regards,
Arun Kumar