请教大家个问题,我现在用spring的AbstractRoutingDataSource配置多个数据源切换,但是却不能实现事务了,
配置了动态数据源
<jee:jndi-lookup id="dataSourceRead"
jndi-name="java:comp/env/jdbc/acc_qz_jiaowu" />
<jee:jndi-lookup id="dataSourceWrite"
jndi-name="java:comp/env/jdbc/acc_qz_jiaowu" />
<bean id="dataSource" class="com.cdeledu.plat.database.DynamicDataSource">
<property name="targetDataSources">
<map key-type="java.lang.String">
<entry key="read" value-ref="dataSourceRead"/>
<entry key="write" value-ref="dataSourceWrite"/>
</map>
</property>
<property name="defaultTargetDataSource" ref="dataSourceRead"/>
</bean>
<!-- SqlMap setup for iBATIS Database Layer -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" value="WEB-INF/sql-map-config.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
在业务层配置了事务,我只需要针对dataSourceWrite数据源做事务
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSourceWrite" />
</bean>
<aop:config>
<aop:advisor pointcut="execution(* *..*Facade.*(..))" advice-ref="txAdvice" />
</aop:config>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="insert*" />
<tx:method name="update*" />
<tx:method name="remove*" />
<tx:method name="delete*" />
<tx:method name="*" read-only="true" />
</tx:attributes>
</tx:advice>
在DAO层会根据需要切换数据源,我只需要对dataSourceWrite数据源的回滚,
可是我发现如果在业务层报了异常却不能回滚,请教大家这是什么原因呢?