Reputation: 41
Hi I am using itemreader, processor and itemwriter, I want my writer to write only specific fields, instead of writing whole item.
For ex.
let say my model class contains below 5 field with there getter & setter method:
RECORD.CLASS
private String ordNo;
private String ordDate;
private String prtDctStsCd;
private String ordRefNo;
private String ordStsCd;
Now my processor is:
public class RecordTableProcessor implements ItemProcessor<Record, Record>{
//somecode
return item; }
Writer: Flatfileitemwriter
Now I want my itemwriter to write only ordNo and ordDate field only. Instead of writing whole 5 item of record class.
Any Idea how to do that? and one more question how can I return only some fields from item processor instead of whole item, is there any way to return what we want?
Upvotes: 0
Views: 359
Reputation: 925
Assume you map ItemReader result to Record class, then in Processor you convert your DTO object to another type, for example SpecificRecord.
return new SpecificRecord(record);
In SpecificRecord only fields that you need.
So in ItemWriter you write new SpecificRecord object.
Upvotes: 0