Below are codes from my xml file
and TestImpl.javaCode:<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>
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?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}); } } }


Reply With Quote
