The key is whatever is being Proxied needs to implement some interface. You don't need to proxy the DAO, or even have the DAO use an interface (although its advisable for testing purposes) if you are using another class to call several operations from the DAO. For example:
To wire it up:Code:public interface DocManager { public void doStuff(); } public class DocManagerImpl { private MyDao dao; public void setDocDao(DocDao dao) { this.dao = dao; } public void doStuff() { dao.call1(); dao.call2(); dao.call3(); } }
Code:<bean id="docManager" class="DocManagerImpl> <property name="docDao" ref="docDao"/> </bean> <bean id="docDao" class=""> <property name="dataSource"><ref local="dataSource"/></property> </bean> <bean id="docProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager"><ref bean="transactionManager"/></property> <property name="target"><ref bean="docManager"/></property> <property name="transactionAttributes"> <props> <prop key="*">PROPAGATION_REQUIRED,-DataAccessException,-SQLException</prop> </props> </property> </bean>


Reply With Quote