I have a spring batch program where I am writing from database to a fixed format file.
My database table consist of 5 columns. All the columns contain description about some product. The column are of type varchar with each sized 200.
I am reading the descriptions from the columns in to my pojo as 5 String properties viz. desc1, desc2, desc3, desc4, desc5.
My item writer looks like below:
<beans:bean id="DbToFileItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter" scope="step">
<beans:property name="resource" value="file:c:\TestData\output.dat" />
<beans:property name="lineAggregator">
<beans:bean class="org.springframework.batch.item.file.transform.FormatterLineAggregator">
<beans:property name="fieldExtractor">
<beans:bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor">
<beans:property name="names" value="desc1, desc2, desc3, desc4, desc5" />
</beans:bean>
</beans:property>
<beans:property name="format" value="%-20s%-30s%-30s%-30s%-30s" />
</beans:bean>
</beans:property>
</beans:bean>
As shown I want desc1 to be in a fixed length field of 20 characters and desc2 through desc4 into fixed length field of 30 characters each into the file.
However, the issue is, I am getting the whole desc string irrespective of the size. That is, if desc1 is 40 characters from database, it is coming as 40 characters in the file as well.
I feel it should only take the first 20 characters and ignore the rest.
What is the issue? Is it a bug or am I doing something wrong ?
Thanks for reading!