I am using spring batch to automatically read csv files and map each row into an object. There is code below. The columns in the csv file are ID, field1, field2, field3. And this is the order I wrote in the lineTokenizer. However, the FlatFileItemReader is not reading the file in this order. Rather, it seemingly reads in a random order, reading field2 first, then ID, then field3, then field1. But I want it to read ID first because I'm trying to write a map that maps ID to each field. Is there a way to change the order in which the FlatFileItemReader reads the columns in csv?
<bean id="mappedPosition" class="com.jpmorgan.ib.colopt.input.MappedPosition" scope="prototype" />
<bean id="positionFileItemReader" class="org.springframework.batch.item.file.FlatFileItemReader">
<property name="resource" value="position.csv" />
<property name="lineMapper">
<bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
<property name="lineTokenizer">
<bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
<property name="names" value="ID, field1, field2, field3" />
</bean>
</property>
<property name="fieldSetMapper">
<bean class="org.springframework.batch.item.file.mapping.BeanWrapperFieldSetMapper">
<property name="prototypeBeanName" value="mappedPosition"/>
</bean>
</property>
</bean>
</property>
</bean>