Skip to content

Commit fcc790a

Browse files
committed
Document how properties are applied in JPA auto-config
Closes gh-15361
1 parent 76f3b13 commit fcc790a

File tree

1 file changed

+5
-0
lines changed
  • spring-boot-project/spring-boot-docs/src/main/asciidoc

1 file changed

+5
-0
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/howto.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,6 +1788,11 @@ Alternatively, you can just the `LocalContainerEntityManagerFactoryBean` directl
17881788
}
17891789
----
17901790

1791+
NOTE: When you create a bean for `LocalContainerEntityManagerFactoryBean` yourself, any customization that was applied during the creation of the auto-configured `LocalContainerEntityManagerFactoryBean` is lost.
1792+
For example, in case of Hibernate, any properties under the `spring.jpa.hibernate` prefix will not be automatically applied to your `LocalContainerEntityManagerFactoryBean`.
1793+
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.
1794+
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.
1795+
17911796
The configuration above almost works on its own.
17921797
To complete the picture, you need to configure `TransactionManagers` for the two `EntityManagers` as well.
17931798
If you mark one of them as `@Primary`, it could be picked up by the default `JpaTransactionManager` in Spring Boot.

0 commit comments

Comments
 (0)