Chapter 7. EntityManagerFactory
Prev | Part 2. Java Persistence API | Next

## Chapter 7. EntityManagerFactory

The `EntityManagerFactory` creates `EntityManager` instances for application use.

| Note
Kodo extends the standard `EntityManagerFactory` interface with the `OpenJPAEntityManagerFactory` to provide additional functionality.

## 7.1. Obtaining an EntityManagerFactory

Within a container, you will typically use injection to access an `EntityManagerFactory`. There are, however, alternative mechanisms for `EntityManagerFactory` construction.

Some vendors may supply public constructors for their `EntityManagerFactory` implementations, but we recommend: using the Java Connector Architecture (JCA) in a managed environment; using the `Persistence` class's `createEntityManagerFactory` methods in an unmanaged environment, as described in Chapter 6, Persistence. These strategies allow vendors to pool factories, cutting down on resource utilization.

JPA allows you to create and configure an `EntityManagerFactory`, then store it in a Java Naming and Directory Interface (JNDI) tree for later retrieval and use.

Prev | Up | Next
6.2. Non-EE Use | Home | 7.2. Obtaining EntityManagers