Table of Contents
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.
OpenJPA offers two EntityManagerFactory
deployment options.
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.
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.