You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The example above creates an `EntityManagerFactory` using a `DataSource` bean named `firstDataSource`.
1814
+
It scans entities located in the same package as `Order`.
1815
+
It is possible to map additional JPA properties using the `app.first.jpa` namespace.
1816
+
1833
1817
NOTE: When you create a bean for `LocalContainerEntityManagerFactoryBean` yourself, any customization that was applied during the creation of the auto-configured `LocalContainerEntityManagerFactoryBean` is lost.
1834
1818
For example, in case of Hibernate, any properties under the `spring.jpa.hibernate` prefix will not be automatically applied to your `LocalContainerEntityManagerFactoryBean`.
1835
1819
If you were relying on these properties for configuring things like the naming strategy or the DDL mode, you will need to explicitly configure that when creating the `LocalContainerEntityManagerFactoryBean` bean.
1836
-
On the other hand, properties that get applied to the auto-configured `EntityManagerFactoryBuilder`, which are specified via `spring.jpa.properties`, will automatically be applied, provided you use the auto-configured `EntityManagerFactoryBuilder` to build the `LocalContainerEntityManagerFactoryBean` bean.
1837
1820
1838
-
The configuration above almost works on its own.
1839
-
To complete the picture, you need to configure `TransactionManagers` for the two `EntityManagers` as well.
1840
-
If you mark one of them as `@Primary`, it could be picked up by the default `JpaTransactionManager` in Spring Boot.
1841
-
The other would have to be explicitly injected into a new instance.
1821
+
You should provide a similar configuration for any additional data sources for which you need JPA access.
1822
+
To complete the picture, you need to configure a `JpaTransactionManager` for each `EntityManagerFactory` as well.
1842
1823
Alternatively, you might be able to use a JTA transaction manager that spans both.
1843
1824
1844
1825
If you use Spring Data, you need to configure `@EnableJpaRepositories` accordingly, as shown in the following example:
0 commit comments