Results 1 to 5 of 5

Thread: transactionManager does not roll back transaction on Exception

Threaded View

  1. #1
    Join Date
    Mar 2010
    Posts
    11

    Default transactionManager does not roll back transaction on Exception

    Below are codes from my xml file

    Code:
    <bean id="testDao" class="myapp.TestImpl">
    	<property name="dataSource" ref="myDataSource" />
    </bean>
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    	<property name="dataSource" ref="myDataSource" />
    </bean>
    <bean id="testDaoProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    	<property name="proxyInterfaces">
    		<list>
    			<value>
    				myapp.TestDao
    			</value>
    		</list>
    	</property>
    	<property name="target">
    		<ref bean="testDao" />
    	</property>
    	<property name="transactionManager">
    		<ref bean="transactionManager" />
    	</property>
    	<property name="transactionAttributes">
    		<props>
    			<prop key="*">
    				PROPAGATION_REQUIRED,-Exception
    			</prop>
    		</props>
    	</property>
    </bean>
    and TestImpl.java
    Code:
    public class TestImpl extends SimpleJdbcDaoSupport implements TestDao{
    	public void insertTest(List<String> list) throws Exception {
    		for (String string : list) {
    			getJdbcTemplate().update("insert into testTab(pcode) values(?)", new Object[]{string});
    		}
    	}
    }
    The List<String> contains 4 values. First 3 values are good but the 4th value violates PK constraint. I expected that the transaction will roll back and no insertion will be done. But it not working - first 3 insertions are done. Any help?
    Last edited by satfaltu; Nov 2nd, 2010 at 09:17 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •