I have to synchronize data from a file (Excel) to a database (MySQL) using Spring Batch.
The file will be processed record by record. Adding and updating database records works fine but I wonder how to detect and delete entries from the database that were removed from the file?
I consider to implement this:
- read the file record-by-record
- create or update the record in the database and remember the primary key
- remove all records with different primary keys (final step after all records have been processed)
Do you know how to collect and pass all processed primary keys to a final step? Or do you recommend another implementation?
Thanks, Patrick
Update: I'm not allowed to alter the database tables.