I have a scenario where I have a Database with some records in it already. I need to replicate the information in other database , with the datasource information derived in the run time.
The entity model remains the same in both the databases and all I need is to migrate the information from one to another.
Related question I found is this : Two datasources using the same entities/repositories using spring data jpa
Also in the solution there it is mentioned to use a 'AbstractRoutingDataSource' which can derive the information from the tenant.
My use case does not fit there exactly, or I do not know how to fit it in.
My requirement is like
DataSource1 -> EntityManager1 -> Persistence Unit1.
DataSoruce2 -> EntityManager2 -> Persistence Unit2.
Both the persistence unit has the same set of classes.
I need to do
EntityRepo_associated_with_datasource1.find()
and then write them to EntityRepo_associated_with_datasource2.saveAll().
Any pointers on this ?