i strongly suggest you do some reading before you progress, getting back here each time doesn't help.
1. Read lines from file no need for a domain object simply pass the string to the ItemProcessor
2. use the id to get something from the database, using the id and that something create an object (use a RowMapper)
3. Write to whatever you want
Not sure how complex that is but imho that is pretty easy and quite straitforward, so not sure what is going wrong. If you return an object from 1 simply enrich it with an itemprocessor. You are thinking way to complex (at least from my point of view).
Code:
public void MyItemProcessor implements ItemProcessor<DomainObject, DomainObject> {
private static final String QUERY= "select name from sometable where id=?;
private final JdbcTemplate jdbcTemplate;
public MyItemProcess(DataSource dataSource) {
super();
this.jdbcTemplate=new JdbcTemplate(dataSource);
}
public DomainObject process(DomainObject obj) {
String name = jdbcTemplate.queryForString(QUERY, obj.getId());
obj.setName(name);
return obj;
}
}
Nothing more nothing less.