Announcement Announcement Module
No announcement yet.
Flat File Item Writer Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Flat File Item Writer

    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
    <bean id="plansReader"
    		class="org.springframework.batch.item.database.JdbcCursorItemReader" scope="step">
    		<property name="dataSource" ref="dataSource" />
    		<property name="sql">
    			<value> <![CDATA[
    				'xxxxToBeProcessed' = case when AR.xxxxToBeProcessed = 1 then '0999' else '0998' end, 
    				 AR.dt , 
    		<property name="rowMapper">
    				class="batch.exports.mapper.CommissionMapper" />
    	<bean id="plansWriter"
    		<property name="delegate" ref="flatFileItemWriter" />
    Java Code
    public class CommissionMapper implements RowMapper {
    	  public CommissionDo mapRow(ResultSet resultSet, int rowNumber) throws SQLException {
            LOGGER.debug("Enter mapRow.");
            CommissionDo commissionDo = new CommissionDo();
    	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 {
    Thanks for your reply in advance.
    Last edited by arun4; Jan 22nd, 2013, 03:24 AM.

  • #2
    While it's a bit hard to read what is going on with such a limited context, I really doubt that overriding the toString method on the DAO is causing any issues (since I can't see why it would even be called). Can you provide the configuration of the job itself? Are you using any multithreaded features?


    • #3
      Thanks a lot for your replay mminella.

      Before running this batch job , XXXXXToBeProcessed indicator is set by some other batch job. Due some business change, the XXXXXToBeProcessed is set to 0 ('0998').

      So the exported data is correct.

      I am so sorry. I am not aware the business changes happened this week.