From 0d9db46f68ab3d496d9055063bd7e2061e9d6294 Mon Sep 17 00:00:00 2001 From: Niclas Fredriksson Date: Tue, 23 Oct 2018 06:13:45 +0200 Subject: [PATCH] Enhance multiple entity manager factories how-to See gh-14928 --- .../spring-boot-docs/src/docs/asciidoc/howto.adoc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc index 25395c1f5e..4f6636f656 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc @@ -1798,9 +1798,10 @@ Spring Boot auto-configuration switches off its entity manager in the presence o -[[howto-use-two-entity-managers]] -=== Use Two EntityManagers -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. +[[howto-use-multiple-entity-managers]] +=== Using Multiple EntityManagerFactories +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. Alternatively, you can use the `LocalContainerEntityManagerFactoryBean` directly from Spring ORM, as shown in the following example: