I am currently using Hibernate solution for my project. This is a standalone service bundled as a library jar file.
We have some transaction handling and currently we are using code level transaction management like HibernateUtil.beginTransaction() , HibernateUtil.commitTransaction() and HibernateUtil.closeSession().
I want to replace only the transaction handling component using Spring. The examples I see on the web entails usage of SpringHibernate support or Spring's implementation for Hibernate. We don't want to disturb our current Hibernate implementation but instead use the existing Hibernate solution reference i.e. just have the Spring transaction handler and make it use the already in place hibernate config for all session management reference rather than reinitializing everything again in Spring configurations.
i have asked this question to myself some time back and found some information.
1. creating data source
2. you have to use spring hibernate session factory.
3. you have to inject spring hibernate session factory to your dao.
4. transaction management can be done by spring aop
5. you have to get session factory in which spring has enabled the transaction management. by righting the code as below
refer sample config
posted 10 years ago
One more question here. Is there a need to repeat configurations for datasource, sesssion factory and hibernate in the spring config xml file.
Since these are already declared in the hibernate.cfg.xml file is there anyway I can refer the hibernate config file for the above mentioned configurations or is it necessary to have the same in Spring.
In the sample you highlighted below the transaction interceptor comes into play during all DAO execution. The approach I am following is controlling transactions at one level above DAO (i.e. a Manager or Service layer) and not doing any transaction related activities within the DAO. So for my case I will just have to replace <value>*DAO</value> with something like <value>*Manager</value>