Commit 0d9db46f authored by Niclas Fredriksson's avatar Niclas Fredriksson Committed by Stephane Nicoll

Enhance multiple entity manager factories how-to

See gh-14928
parent a1a2f00b
...@@ -1798,9 +1798,10 @@ Spring Boot auto-configuration switches off its entity manager in the presence o ...@@ -1798,9 +1798,10 @@ Spring Boot auto-configuration switches off its entity manager in the presence o
[[howto-use-two-entity-managers]] [[howto-use-multiple-entity-managers]]
=== Use Two EntityManagers === Using Multiple EntityManagerFactories
Even if the default `EntityManagerFactory` works fine, you need to define a new one, otherwise the presence of the second bean of that type switches off the default. Sometimes you may wish to work with multiple Entity Manager Factories, because you have multiple data sources.
In those cases, you need to create your own `EntityManagerFactory` for each datasource.
You can use the `EntityManagerBuilder` provided by Spring Boot to help you to create one. You can use the `EntityManagerBuilder` provided by Spring Boot to help you to create one.
Alternatively, you can use the `LocalContainerEntityManagerFactoryBean` directly from Spring ORM, as shown in the following example: Alternatively, you can use the `LocalContainerEntityManagerFactoryBean` directly from Spring ORM, as shown in the following example:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment