I have an application that periodically downloads a large XML and saves it into a database. What is the proper way to deal with failure during the insertion process. Current process:
- download XML
- parse XML
- clear current data
- insert data into database <= spans thousands of rows over 8 different tables
I would like to be able to do a backup before step 4 and if step 4 fails restore the data from backup. Currently using ebean to do persistence. I was trying to use temporary tables and copy all data there and if case of failure copy data back, but I am not sure how to hold on to a single session while waiting for 4 to finish.
you can use Savepoint see savepoints in ebean:
transaction.setNestedUseSavepoint() :