Hi all,
I'm doing audit Trail by using Hibernate's EmptyIntercpetor.
1)I'm storing record using SessionFactory(DI in DAO) inside DAO.
2) when a record gets change i'm storing its value in DB(so for this agian i need SeessionFactory to store record),so this parts needed SessionFactory as Dependancy.
3)But EmptyInterceptor need to DI in SessionFactory to intercept records which affect DB.
So Dependancy goes like this
SessionFactory -> DAO -> EmptyInterceptor -> SessionFactory
Any DAO look like this..Code:<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"><ref bean="dataSource"/></property> <property name="mappingLocations"><ref bean="hibernateMappingLocations"/></property> <property name="hibernateProperties"><ref bean="hibernateProperties"/></property> <property name="entityInterceptor"> <ref local="auditTrailInterceptor"/> </property> <!-- applicationContext sessionFactory merge-point --> </bean> <bean id="auditTrailInterceptor" class="AuditTrailInterceptor"> </bean>
Hope above explains how circular Dependancy happens here. Which is not part of any Conceptual prob.Code:<bean id="XXXDao" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="target"> <bean class="XXXDaoImpl"> <property name="sessionFactory"><ref local="sessionFactory"/></property> </bean> </property> <property name="proxyInterfaces"> <value>ItemGroupDao</value> </property> <property name="interceptorNames"> <list> <value>hibernateInterceptor</value> </list> </property> </bean>
Can anyone help me for removing this Circular Dependency?


Reply With Quote