Reputation: 133
I am trying to figure out how to insert the exact same data into two different databases with the same schema. I found this Multiple datasources with same repositories and entities but it didnt really answer the question.
Say I have a user who is registering and I want to save this user to both databases. How do I do I configure this in spring boot? I have seen different repos/databases but what I want is to use the same repo/entity. I know replication is a thing in databases already but I want to do this on the application level.
Upvotes: 2
Views: 8452
Reputation: 3166
The solution you are searching is well discussed in this artiche with the save action here
Just a couple of notes... You can configure two database and you can also set the same entities, but you cannot point at the same repository because each repository is related to a specific dataSource
and transactionManager
. Moreover, if you want to have the same entity ids
across two databases you have to manage them manually.
Upvotes: 8