Reputation: 951
Currently I need to implement the following steps with Spring batch:
Technically I have no problem dealing with step 1 and step 3, but anyone could advise how to tackle step 2? I understand that after step 1 I can get a rowMapper class that maps each row of data to my domain object, in this case how to pass the column values (domain object attributes) as the parameters to step 2?
Upvotes: 0
Views: 2065
Reputation: 125292
As I tried to explain in the comments (and in the link to the documentation). Use a chunk oriented step. Your sequence corresponds to the following
For the reader you could use a JdbcCursorItemReader
together with a RowMapper
to convert the result into an object. In the ItemProcessor
you use a JdbcTemplate
with a query and use the incoming object to add the parameters to the query, together with another RowMapper
this will convert the result into an object. This object is passed to the ItemWriter
which stores the object you could use a JdbcBatchItemWriter
for that.
Depending on your needs for step 2/3 you could try to create a custom writer which does the processing (reading/updating) in a single query (this could be faster then reading, constructing objects and writing again).
Upvotes: 2
Reputation: 10034
Why don't you create Staging table in Datasource B( I assume its different database). And tweek your query. Hence your step would be
Upvotes: 1