@@ -268,10 +268,17 @@ The actual JPA provider bootstrapping is handed off to the specified executor an
268
268
running in parallel, to the application bootstrap thread. The exposed `EntityManagerFactory`
269
269
proxy can be injected into other application components and is even able to respond to
270
270
`EntityManagerFactoryInfo` configuration inspection. However, once the actual JPA provider
271
- is being accessed by other components (for example, calling `createEntityManager`), those calls
272
- block until the background bootstrapping has completed. In particular, when you use
271
+ is being accessed by other components (for example, calling `createEntityManager`), those
272
+ calls block until the background bootstrapping has completed. In particular, when you use
273
273
Spring Data JPA, make sure to set up deferred bootstrapping for its repositories as well.
274
274
275
+ As of 6.2, JPA initialization is enforced before context refresh completion, waiting for
276
+ asynchronous bootstrapping to complete by then. This makes the availability of the fully
277
+ initialized database infrastructure predictable and allows for custom post-initialization
278
+ logic in `ContextRefreshedEvent` listeners etc. Putting such application-level database
279
+ initialization into `@PostConstruct` methods or the like is not recommended; this is
280
+ better placed in `Lifecycle.start` (if applicable) or a `ContextRefreshedEvent` listener.
281
+
275
282
276
283
[[orm-jpa-dao]]
277
284
== Implementing DAOs Based on JPA: `EntityManagerFactory` and `EntityManager`
@@ -284,9 +291,9 @@ to a newly created `EntityManager` per operation, in effect making its usage thr
284
291
285
292
It is possible to write code against the plain JPA without any Spring dependencies, by
286
293
using an injected `EntityManagerFactory` or `EntityManager`. Spring can understand the
287
- `@PersistenceUnit` and `@PersistenceContext` annotations both at the field and the method level
288
- if a `PersistenceAnnotationBeanPostProcessor` is enabled. The following example shows a plain
289
- JPA DAO implementation that uses the `@PersistenceUnit` annotation:
294
+ `@PersistenceUnit` and `@PersistenceContext` annotations both at the field and the method
295
+ level if a `PersistenceAnnotationBeanPostProcessor` is enabled. The following example
296
+ shows a plain JPA DAO implementation that uses the `@PersistenceUnit` annotation:
290
297
291
298
[tabs]
292
299
======
0 commit comments