Reputation: 1549
I have two databases that have the exact same tables. They have the same model. I want to create a simple Spring Boot application that will copy some records from one DB to the other. Both DBs are form the same vendor.
Ideally I would like to have one domain model and simply assign the adequate datasource based on my needs, possibly through the @Qualified annotation.
Another workaround would be to duplicate the domain model and create two configurations for each database.
What is the correct way of solving this problem?
Thank you in advance
Upvotes: 1
Views: 637
Reputation: 30429
You should create a project with two modules: one - with your model, another - with two data sources and repos for every entity in these DBs. Then in the second module you can work with data from two data sources.
For example:
Project:
- module: 'model':
- entity1
- entity2
- module: 'work'
- data source #1:
- repo1_1
- repo1_2
- data source #2:
- repo2_1
- repo2_2
Upvotes: 2