I am using DataSourceTransactionManage for writing into two tables. I made the connection object null before I insert into the second table to see if the operation rolls back , but the insert into the first table wont rollback.
Here is the java code toCode:<bean id="TestDS" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close" scope="singleton"> <property name="connectionCachingEnabled" value="true" /> <property name="URL"> <value>jdbc:oracle:thin:@10.8.237.211:1521:orcl</value> </property> <property name="user"> <value>Muthu_TWE82_Sep27</value> </property> <property name="password"> <value>Muthu_TWE82_Sep27</value> </property> <property name="connectionProperties"> <value> autoCommit:false </value> </property> <property name="connectionCacheProperties"> <value> MinLimit:20 MaxLimit:150 InitialLimit:5 ConnectionWaitTimeout:10 InactivityTimeout:180 ValidateConnection:false </value> </property> </bean> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="TestDS"/> </bean>
I did a remote debug from Eclipse and found that object ID of the connection object in "doBegin()" & "doRollback" of DataSourceTransactionManager is not the same as the object ID of the connection object that I get in the java code using the datasource.Code:Connection con = SpringUtil.getInstance().getConnection("TestDS"); insertTable1(con); con=null; insertTable2(con);
I think that this is the reason that the insert operation are not rolled back as the rollback is called on a difference connection object.
I also tried the scope="singleton" but it doesn't help.
Please share you suggestions.


Reply With Quote
