Hi Rob,
Because I'm porting exist codes from an EJB app to Spring, I don't have the luxury to use JdbcTemplate. I've tried modifying my original datasource & transaction manger configuration as follow, but I still could not get it to work. I even stepped into the codes & confirmed that the dataSource is an instanceof TransactionAwareDataSourceProxy
Code:
<bean id="activeDataSourceImpl" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property>
<property name="url"><value>jdbc:oracle:thin:@hostname:1521:orange</value></property>
<property name="username"><value>user</value></property>
<property name="password"><value>pw</value></property>
</bean>
<bean id="activeDataSource"
class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy">
<property name="targetDataSource">
<ref bean="activeDataSourceImpl"/>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="activeDataSourceImpl"/>
</property>
</bean>
Interestingly, the datasource transaction manager works fine for the following configuration.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="activeDataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property>
<property name="url"><value>jdbc:oracle:thin:@hostname:1521:orange</value></property>
<property name="username"><value>user</value></property>
<property name="password"><value>pw</value></property>
</bean>
<bean id="activeTransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource">
<ref bean="activeDataSource"/>
</property>
</bean>
<bean id="boxHandlingServiceTarget"
class="com.beans.BoxHandling.BoxHandlingServiceImpl"
lazy-init="true">
<property name="activeDataSource">
<ref bean="activeDataSource"/>
</property>
</bean>
<bean id="boxHandlingService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
lazy-init="true">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref local="boxHandlingServiceTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
</beans>