Hello everyone,
I'm using Spring's HibernateInterceptor for my DAOs, in order to get sessions attached to them. Here's an example of my TargetProxy:
The problem I have is, when I have controllers that need access to the DAOs, it's awkward to inject the DAOs through every time. I was mistakenly using MemberDAO.getInstance() in the code, until I realized the getInstance() call bypasses the HibernateInterceptor.Code:<bean id="MemberDAOTarget" class="org.phatcast.db.dao.MemberDAOImpl" factory-method="getInstance"> <property name="sessionFactory"> <ref bean="mySessionFactory"/> </property> </bean> <bean id="MemberDAO" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <value>org.phatcast.db.dao.MemberDAO</value> </property> <property name="interceptorNames"> <list> <value>myHibernateInterceptor</value> <value>MemberDAOTarget</value> </list> </property> </bean>
Is there an easy way to get access to these DAOs without constantly creating setDao() methods in every controller, and changing the XML around? Is anyone is directly looking up the beans in the ApplicationContext? Or any other thoughts?
I would very much appreciate it if anyone had advice as to the best way to use HibernateInterceptor.
Andrew
Seattle, WA


Reply With Quote
Thanks.