I need to insert or update records based on whether record already exist.
I am using JdbcBatchItemWriter to write the records. but if the record with the primary key already exist, I should update it...
So one solution is:
To make two seperate lists one for insert and one for update(note: I have to check in my processor every time whether the record already exist and thus add the record in one of the list), and have two different JdbcBatchItemWriter instances in my writer, for example:
JdbcBatchItemWriter<insertList> insertWriter;
JdbcBatchItemWriter<updateList> updateWriter;
Is there any other way to switch between the queries in writer based on record already exist at the time of batch update...i.e. just one
JdbcBatchItemWriter<mylist> allWriter...and
allWriter.write(mylistallitems);
I am thinking of using a merge query...but are there any performance issues?