Force commit in batch update
Hi all,
I need to do a batch insert/update of a few hundreds records in a table. I am using Spring 1.1.1 with Ibatis sql map. What I want to achieve is this:
(assuming total no of records = 100)
Record 1: insert successfully
Record 2: insert successfully
Record 3: insert successfully
Record 4: Update Failed
.
.
.
Record 100: insert successfully
Snippets of my code:
BusinessFacadeImpl.java
Code:
public class BusinessFacadeImpl implments BusinessFacade {
private BusinessDao businessDao;
public BusinessDao setBusinessDao(BusinessDao businessDao) {
this.businessDao = businessDao;
}
void batchUpdate() {
try {
businessDao.batchUpdate();
} catch (Throwable t) {
throw new ApplicationException(t);
}
}
}
application-context.xml
Code:
<bean id="baseTx" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="target"><ref local="codewordTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="batch*">PROPAGATION_REQUIRED,+ApplicationException</prop>
</props>
</property>
</bean>
This can only force commit for my record 1, 2 and 3 and stop proceeding after record 4. What I really want is to ignore the exception in record 4 and proceed to inserting/updating for the rest of my records. I have tried various ways like "PROPAGATION_NEVER" or renaming the method but still in vain. Please kindly advise me on this. Thanks.