diff --git a/src/docbkx/jpa.xml b/src/docbkx/jpa.xml
index 0d5dacd05..9699a63e1 100644
--- a/src/docbkx/jpa.xml
+++ b/src/docbkx/jpa.xml
@@ -1270,7 +1270,8 @@ class Config {
You can now set up the infrastructure by implementing a CDI
Producer for the
- EntityManagerFactory:
+ EntityManagerFactory and
+ EntityManager:
class EntityManagerFactoryProducer {
@@ -1283,8 +1284,36 @@ class Config {
public void close(@Disposes EntityManagerFactory entityManagerFactory) {
entityManagerFactory.close();
}
+
+ @Produces
+ @RequestScoped
+ public EntityManager createEntityManager(EntityManagerFactory entityManagerFactory) {
+ return entityManagerFactory.createEntityManager();
+ }
+
+ public void close(@Disposes EntityManager entityManager) {
+ entityManager.close();
+ }
}
+ The necessary setup can vary depending on the JavaEE environment
+ you run in. It might also just be enough to redeclare a
+ EntityManager as CDI bean as
+ follows:
+
+ class CdiConfig {
+
+ @Produces
+ @RequestScoped
+ @PersistenceContext
+ public EntityManager entityManager;
+}
+
+ In this example, the container has to be capable of creating JPA
+ EntityManagers itself. All the
+ configuration does is re-exporting the JPA
+ EntityManager as CDI bean.
+
The Spring Data JPA CDI extension will pick up all
EntityManagers availables as CDI beans
and create a proxy for a Spring Data repository whenever an bean of a