JPOX
JPOX
 Project  |  Ver 1.1  |  Ver 1.2  |  JDO  |  JPA  |  Guides  |  Tools
1.2 | Persistence | JDO ORM | JPA ORM | Runtime | JDO Runtime | JPA Runtime | Extensions | Developer
JPA Runtime
JPA Queries
Entity Manager Factory

Any JPA-enabled application will require at least one EntityManagerFactory. Typically applications create one per datastore being utilised. An EntityManagerFactory provides access to EntityManagers which allow objects to be persisted, and retrieved. The EntityManagerFactory can be configured to provide particular behaviour.

The simplest way of creating an EntityManagerFactory in a J2SE environment is as follows

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

...

EntityManagerFactory emf = Persistence.createEntityManagerFactory(persistenceUnitName);

So you simply provide the name of the persistence-unit which defines the properties, classes, metadata etc to be used. An alternative is to specify the properties to use along with the persistence-unit name. In that case the passed properties will override any that are specified for the persistence unit itself.

TODO Add a description of the available properties

Standard JPA Properties
ParameterValuesDescription
javax.persistence.providerClass name of the provider to use. JPOX has a provider name of org.jpox.jpa.PersistenceProviderImpl
javax.persistence.transactionTypeRESOURCE_LOCAL | JTAType of transactions to use. In J2SE the default is RESOURCE_LOCAL. In J2EE the default is JTA.
javax.persistence.jtaDataSourceJNDI name of a (transactional) JTA data source.
javax.persistence.nonJtaDataSourceJNDI name of a (non-transactional) data source.


Extension JPOX Properties

JPOX provides many properties to extend the control that JPA gives you. These can be used alongside teh above standard JPA properties, but will only work with JPOX. Please consult the Persistence Properties Guide for full details.