1

I have a compositeItemWriter that has 2 delegate writers : 1. HeaderWriter to write some fields from my object to Header Table 2. DetailWriter to write fileds to a detail table.

Issue is, when an exception occurs in DetailWriter, data is not getting rolled back from the Headerwriter. Looks like data is being updated in 2 different transactions. How do I enforce data integrity by having both updates in the same transaction ?


FYI, I am using Informix and had to extend some of the Spring batch classes to get Spring working on Informix.

My configuration is as follows :

Section from my reportjob.xml :

<bean id="programHeaderWriter"   
class="com.bah.discrepancy.writer.ProgramHeaderWriter">
    <property name="dataSource" ref="dataSource" />  
    <property name="itemSqlParameterSourceProvider">
    <bean   
 class="com.bah.discrepancy.parametermapper.ProgramHdrParameterMapper"/>
    </property>
 </bean>
<bean id="programDetailWriter"  
class="com.bah.discrepancy.writer.ProgramDetailWriter">
    <property name="dataSource" ref="dataSource" />  
    <property name="itemSqlParameterSourceProvider">
    <bean 
 class="com.bah.discrepancy.parametermapper.ProgramDetailParamMapper" />
    </property>
 </bean>

Context.xml :

<bean id="transactionManager"       
class="org.springframework.batch.support.transaction.ResourcelessTransaction
    Manager" />

<bean id="batchDefaultSerializer"  
class="org.springframework.batch.core.repository.dao.
DefaultExecutionContextSerializer" />

<bean id="dataSource"  
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.informix.jdbc.IfxDriver"
         />
        <property name="url" value="<URL>" />
        <property name="username" value="<UserID>" />
        <property name="password" value="<Password>" />
    </bean>



    <bean id="jobRepository"  
     class="com.bah.batch.informixsupport.InformixJobRepositoryFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="databaseType" value="Informix"/>
        <property name="incrementerFactory" ref="informixIncrementer"/>
        <property name="transactionManager" ref="transactionManager"/>
        <property name="tablePrefix" value="BATCH_" />
    </bean>
Radhika
  • 91
  • 1
  • 13

1 Answers1

0

hope this is resolved by this time for sure. But just wanted to check if you have fixed the issue in the following way or any other way?

Spring Batch CompositeItemWriter Transaction Roll back issue

Community
  • 1
  • 1
techi
  • 133
  • 2
  • 15