Hi
Am a beginner to Spring.
I have an existing application in hibernate. There is a plan to implement Spring in the application and using spring-hibernate. This should happen with as much minimal changes as possible to the existing code.
My current application structure is as follows:
Current application has one Generic DAO which has all standard methods to retrieve and persist. And all the dao's extend this generic DAO and they will have custom methods which handles complex queries.
We are passing session to the DAO's through constructor and using that session for executing the queries.
1. Now If want to use Spring-Hibernate, using HibernateTemplate is the best, but I have to touch all the DAO's and each and every method in those DAO's to wrap the queries with hibernate template. Please suggest if you have some thing better, which we can be injected into the DAO's without touching the all the methods in the DAO.
2. One solution that I have is, use getSession() of HibernateSupportDAO instead of hibernateTemplate(). And I'll be implementing transactions through Spring AOP. If so, will the session closing be handled by the transaction interceptor? Or Do I need to take care of closing the session in the code explicitly?
Could any one please provide a suggestion?
Thanks in Advance.


Reply With Quote
