Chapter 8. Deployment
Prev | Part 3. Reference Guide | Next

## Chapter 8. Deployment

OpenJPA deployment includes choosing a factory deployment strategy, and in a managed environment, optionally integrating with your application server's managed and XA transactions. This chapter examines each aspect of deployment in turn.

## 1. Factory Deployment

OpenJPA offers two `EntityManagerFactory` deployment options.

### 1.1. Standalone Deployment

The JPA Overview describes the `jakarta.persistence.Persistence` class. You can use `Persistence` to obtain `EntityManagerFactory` instances, as demonstrated in Chapter 6, Persistence . OpenJPA also extends `Persistence` to add additional `EntityManagerFactory` creation methods. The `org.apache.openjpa.persistence.OpenJPAPersistence` class Javadoc details these extensions.

After obtaining the factory, you can cache it for all `EntityManager` creation duties. OpenJPA factories support being bound to JNDI as well.

### 1.2. EntityManager Injection

Java EE application servers allow you to inject entity managers into your session beans using the `PersistenceContext` annotation. See your application server documentation for details.

Prev | Up | Next
11. Orphaned Keys | Home | 2. Integrating with the Transaction Manager