2

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.

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, the article you posted helped.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.