2. Runtime Configuration
Prev | Chapter 2. Configuration | Next

## 2. Runtime Configuration

The OpenJPA runtime includes a comprehensive system of configuration defaults and overrides:

- OpenJPA first looks for an optional `openjpa.xml` resource. OpenJPA searches for this resource in each top-level directory of your `CLASSPATH`. OpenJPA will also find the resource if you place it within a `META-INF` directory in any top-level directory of the `CLASSPATH`. The `openjpa.xml` resource contains property settings in JPA's XML format.

- You can customize the name or location of the above resource by specifying the correct resource path in the `openjpa.properties` System property.

- You can override any value defined in the above resource by setting the System property of the same name to the desired value.

- In JPA, the values in the standard `META-INF/persistence.xml` bootstrapping file used by the `Persistence` class at runtime override the values in the above resource, as well as any System property settings. The `Map` passed to `Persistence.createEntityManagerFactory` at runtime also overrides previous settings, including properties defined in `persistence.xml`.

- In JPA, The `Map` passed to the methods defined in the `Query` and `EntityManager` interfaces at runtime also overrides previous settings, including properties defined in `persistence.xml`. The `Map` is in effect only during the method invocation.

- When using JCA deployment the `config-property` values in your `ra.xml` file override other settings.

- All OpenJPA command-line tools accept flags that allow you to specify the configuration resource to use, and to override any property. Section 3, “ Command Line Configuration ” describes these flags.

### Note

Internally, the OpenJPA runtime environment and development tools manipulate property settings through a general `Configuration` interface, and in particular its `OpenJPAConfiguration` and `JDBCConfiguration` subclasses. For advanced customization, OpenJPA's extended runtime interfaces and its development tools allow you to access these interfaces directly. See the Javadoc for details.

Prev | Up | Next
Chapter 2. Configuration | Home | 3. Command Line Configuration