Two Steps to integrate Hibernate with Spring:
1) Define DataSource & Hibernate SessionFactory in the spring application context file.
2) Now to integrate the Hibernate with your application DAO class - there are three ways / options:
2.1)) Extending 'HibernateDaoSupport' (using Inheritance)
2.2)) Injecting 'HibernateTemplate' (using Composition)
2.3)) Directly injecting the Hibernate sesisonFactory in your DAO class. In this case - there would not be any dependency upon any Spring f/w class.
If you are using Hibernate 3.x - you shall go with 3rd option.
References:
http://www.techfaq360.com/tutorial/spring/springhibernate.jsp
http://bwinterberg.blogspot.in/2009/08/comparison-implementing-hibernate-daos.html
http://java-x.blogspot.in/2008/04/integrating-spring-and-hibernate.html
http://www.vaannila.com/spring/spring-hibernate-integration-1.html
1) Define DataSource & Hibernate SessionFactory in the spring application context file.
2) Now to integrate the Hibernate with your application DAO class - there are three ways / options:
2.1)) Extending 'HibernateDaoSupport' (using Inheritance)
2.2)) Injecting 'HibernateTemplate' (using Composition)
2.3)) Directly injecting the Hibernate sesisonFactory in your DAO class. In this case - there would not be any dependency upon any Spring f/w class.
If you are using Hibernate 3.x - you shall go with 3rd option.
References:
http://www.techfaq360.com/tutorial/spring/springhibernate.jsp
http://bwinterberg.blogspot.in/2009/08/comparison-implementing-hibernate-daos.html
http://java-x.blogspot.in/2008/04/integrating-spring-and-hibernate.html
http://www.vaannila.com/spring/spring-hibernate-integration-1.html
No comments:
Post a Comment