Results 1 to 3 of 3

Thread: Flat File Item Writer

  1. #1

    Default 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
    Code:
    <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>
    Java Code
    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);
    			}
    		}
    Thanks for your reply in advance.
    Last edited by arun4; Jan 22nd, 2013 at 02:24 AM.
    Thanks & Regards,
    Arun Duraisamy

  2. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    351

    Default

    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?
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  3. #3

    Default

    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.
    Thanks & Regards,
    Arun Duraisamy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •