Hi All,
I have implemented the Use case to export the data to file.
My Reader : Reads the data from database tables and based on one indicator it set error code '0999' and '0998'
Writer : Collect the account information and delegate the object to the FlatFileItemWriter.
Issue: some times the value assigned for setXXXXXToBeProcessed is getting changed from 0999 to 0998
I have checked the reader query it giving correct result and while writing to file it getting changed.
It is happening in the production environment(AIX). We have extracted the incorrect data and ran in local environment(Windows) its ran without any issue.
is override toString() is causing issue? or JdbcCursorItemReader result set?
XML data
Java CodeCode:<bean id="plansReader" class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="step"> <property name="dataSource" ref="dataSource" /> <property name="sql"> <value> <![CDATA[ Ar.account, 'xxxxToBeProcessed' = case when AR.xxxxToBeProcessed = 1 then '0999' else '0998' end, AR.dt , ... ]]> </value> </property> <property name="rowMapper"> <bean class="batch.exports.mapper.CommissionMapper" /> </property> </bean> <bean id="plansWriter" class="batch.exports.writer.PlansWriter"> <property name="delegate" ref="flatFileItemWriter" /> </bean>
Thanks for your reply in advance.Code:public class CommissionMapper implements RowMapper { public CommissionDo mapRow(ResultSet resultSet, int rowNumber) throws SQLException { LOGGER.debug("Enter mapRow."); CommissionDo commissionDo = new CommissionDo(); ... commissionDo.setXXXXXToBeProcessed(resultSet.getString(XXXXX_TO_BE_PROCESSED)); ... } public class CommissionDo implements Serializable { ... ... public String toString() { return (getRecordType() + ..... + + ExportConstants.TILDE_SEPARATOR + getXXXXXToBeProcessed() + ExportConstants.TILDE_SEPARATOR ...... .... } } public class PlansWriter implements ItemWriter<CommissionDo>, ItemStream, StepExecutionListener { public void write(List<? extends CommissionDo> commissionDoList) throws BatchBusinessException { ....... delegate.write(commissionDoList); } }


Reply With Quote