Configuration
configuration
Introduction
This chapter describes the OpenJPA configuration framework. It concludes with
descriptions of all the configuration properties recognized by OpenJPA. You may
want to browse these properties now, but it is not necessary. Most of them will
be referenced later in the documentation as we explain the various features they
apply to.
Runtime Configuration
configuration
runtime
The OpenJPA runtime includes a comprehensive system of configuration defaults
and overrides:
openjpa.xml
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.
Persistence
createEntityManagerFactory
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.
describes these flags.
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.
Command Line Configuration
configuration
command line
OpenJPA development tools share the same set of configuration defaults and
overrides as the runtime system. They also allow you to specify property values
on the command line:
-properties/-p <configuration file or resource>: Use
the -properties flag, or its shorter -p
form, to specify a configuration file to use. Note that OpenJPA always searches
the default file locations described above, so this flag is only needed when you
do not have a default resource in place, or when you wish to override the
defaults. The given value can be the path to a file, or the resource name of a
file somewhere in the CLASSPATH. OpenJPA will search the
given location as well as the location prefixed by META-INF/
. Thus, to point an OpenJPA tool at
META-INF/my-persistence.xml, you can use:
<tool> -p my-persistence.xml
If you want to run a tool against just one particular persistence unit in
a configuration file, you can do so by specifying an anchor along with the
resource. If you do not specify an anchor, the tools will run against all
the persistence units defined within the specified resource, or the default
resource if none is specified. If the persistence unit is defined within
the default resource location, then you can just specify the raw anchor itself:
<tool> -p my-persistence.xml#sales-persistence-unit
<tool> -p #invoice-persistence-unit
-<property name> <property value>: Any
configuration property that you can specify in a configuration file can be
overridden with a command line flag. The flag name is always the last token of
the corresponding property name, with the first letter in either upper or lower
case. For example, to override the openjpa.ConnectionUserName
property, you could pass the -connectionUserName <value>
flag to any tool. Values set this way override both the values in the
configuration file and values set via System properties.
Code Formatting
code formatting
Some OpenJPA development tools generate Java code. These tools share a common
set of command-line flags for formatting their output to match your coding
style. All code formatting flags can begin with either the codeFormat
or cf prefix.
-codeFormat./-cf.tabSpaces <spaces>: The number of
spaces that make up a tab, or 0 to use tab characters. Defaults to using tab
characters.
-codeFormat./-cf.spaceBeforeParen <true/t | false/f>:
Whether or not to place a space before opening parentheses on method calls, if
statements, loops, etc. Defaults to false.
-codeFormat./-cf.spaceInParen <true/t | false/f>:
Whether or not to place a space within parentheses; i.e. method( arg)
. Defaults to false.
-codeFormat./-cf.braceOnSameLine <true/t | false/f>:
Whether or not to place opening braces on the same line as the declaration that
begins the code block, or on the next line. Defaults to true
.
-codeFormat./-cf.braceAtSameTabLevel <true/t | false/f>
: When the braceOnSameLine option is disabled, you can choose
whether to place the brace at the same tab level of the contained code. Defaults
to false.
-codeFormat./-cf.scoreBeforeFieldName <true/t | false/f>
: Whether to prefix an underscore to names of private member
variables. Defaults to false.
-codeFormat./-cf.linesBetweenSections <lines>: The
number of lines to skip between sections of code. Defaults to 1.
Code Formatting with the Application Id Tool
java org.apache.openjpa.enhance.ApplicationIdTool -cf.spaceBeforeParen true -cf.tabSpaces 4
Plugin Configuration
configuration
plugins
plugins
configuration
Because OpenJPA is a highly customizable environment, many configuration
properties relate to the creation and configuration of system plugins. Plugin
properties have a syntax very similar to that of Java 5 annotations. They allow
you to specify both what class to use for the plugin and how to configure the
public fields or bean properties of the instantiated plugin instance. The
easiest way to describe the plugin syntax is by example:
OpenJPA has a pluggable L2 caching mechanism that is controlled by the
openjpa.DataCache configuration property. Suppose that you have
created a new class, com.xyz.MyDataCache, that you want
OpenJPA to use for caching. You've made instances of MyDataCache
configurable via two methods, setCacheSize(int size)
and setRemoteHost(String host). The
sample below shows how you would tell OpenJPA to use an instance of your custom
plugin with a max size of 1000 and a remote host of cacheserver
.
<property name="openjpa.DataCache"
value="com.xyz.MyDataCache(CacheSize=1000, RemoteHost=cacheserver)"/>
As you can see, plugin properties take a class name, followed by a
comma-separated list of values for the plugin's public fields or bean properties
in parentheses. OpenJPA will match each named property to a field or setter
method in the instantiated plugin instance, and set the field or invoke the
method with the given value (after converting the value to the right type, of
course). The first letter of the property names can be in either upper or lower
case. The following would also have been valid:
com.xyz.MyDataCache(cacheSize=1000, remoteHost=cacheserver)
If you do not need to pass any property settings to a plugin, you can just name
the class to use:
com.xyz.MyDataCache
Similarly, if the plugin has a default class that you do not want to change, you
can simply specify a list of property settings, without a class name. For
example, OpenJPA's query cache companion to the data cache has a default
implementation suitable to most users, but you still might want to change the
query cache's size. It has a CacheSize property for this
purpose:
CacheSize=1000
Finally, many of OpenJPA's built-in options for plugins have short alias names
that you can use in place of the full class name. The data cache property, for
example, has an available alias of true for the standard
cache implementation. The property value simply becomes:
true
The standard cache implementation class also has a CacheSize
property, so to use the standard implementation and configure the size, specify:
true(CacheSize=1000)
The remainder of this chapter reviews the set of configuration properties
OpenJPA recognizes.
OpenJPA Properties
configuration
of OpenJPA properties
OpenJPA defines many configuration properties. Most of these properties are
provided for advanced users who wish to customize OpenJPA's behavior; the
majority of developers can omit them. The following properties apply to any
OpenJPA back-end, though the given descriptions are tailored to OpenJPA's
default JDBC store.
Few of the properties recognized by OpenJPA have been standardized in JPA 2.0
Specification using equivalent names. These properties can be specified either
by the JPA standard key or equivalent OpenJPA key. Specifying the same key once
as JPA standard key and again as equivalent OpenJPA key in the same configuration,
however, is not allowed. The following table lists these standard JPA properties
and their OpenJPA equivalent.
Standard JPA Properties and OpenJPA equivalents
Standard JPA 2.0OpenJPA Equivalentjavax.persistence.jdbc.driveropenjpa.ConnectionDriverNamejavax.persistence.jdbc.urlopenjpa.ConnectionURLjavax.persistence.jdbc.useropenjpa.ConnectionUserNamejavax.persistence.jdbc.passwordopenjpa.ConnectionPassword
openjpa.AutoClear
AutoClear
transactions
AutoClear
AutoClear
Property name: openjpa.AutoClear
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getAutoClear
Resource adaptor config-property:
AutoClearDefault: datastorePossible values: datastore,
allDescription: When to automatically clear
instance state: on entering a datastore transaction, or on entering any
transaction.
openjpa.AutoDetach
AutoDetach
detach
AutoDetach
AutoDetach
Property name: openjpa.AutoDetach
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getAutoDetach
Resource adaptor config-property:
AutoDetachDefault: -
Possible values: close,
commit, nontx-readDescription: A comma-separated list of events
when managed instances will be automatically detached.
openjpa.BrokerFactory
BrokerFactory
Property name: openjpa.BrokerFactory
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getBrokerFactory
Resource adaptor config-property:
BrokerFactoryDefault: jdbcPossible values: jdbc,
abstractstore, remoteDescription: A plugin string (see
) describing the
org.apache.openjpa.kernel.BrokerFactory type to
use.
openjpa.BrokerImpl
BrokerImpl
Broker
BrokerImpl
Property name: openjpa.BrokerImpl
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getBrokerImpl
Resource adaptor config-property:
BrokerImplDefault: defaultDescription: A plugin string (see
) describing the
org.apache.openjpa.kernel.Broker type to use at runtime. See
on for details.
openjpa.CallbacksCallbacksCallbacksCallbacksProperty name: openjpa.CallbacksConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getCallbackOptionsInstanceResource adaptor config-property: CallbacksDefault: defaultDescription: A plugin string (see
) to fine tune some of the configurable
properties related to callbacks. The plug-in supports two boolean properties:
PostPersistCallbackImmediate: whether the
post-persist callback is invoked as soon as a new instance
is managed. The default is false, implies that
the post-persist callback is invoked after the instance been committed
or flushed to the datastore.
AllowsMultipleMethodsForSameCallback: whether
multiple methods of the same class can handle the same callback event.
Defaults to false.
openjpa.ClassResolver
ClassResolver
class loading
ClassResolver
Property name: openjpa.ClassResolver
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getClassResolver
Resource adaptor config-property:
ClassResolverDefault: defaultDescription: A plugin string (see
) describing the
org.apache.openjpa.util.ClassResolver implementation to use
for class name resolution. You may wish to plug in your own resolver if you have
special classloading needs.
openjpa.Compatibility
Compatibility
backwards compatibility
Property name: openjpa.Compatibility
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getCompatibility
Resource adaptor config-property:
CompatibilityDefault: -
Description: Encapsulates options to mimic the
behavior of previous OpenJPA releases.
openjpa.ConnectionDriverName
ConnectionDriverName
connections
ConnectionDriverName
Property name:
openjpa.ConnectionDriverNameConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionDriverName
Resource adaptor config-property:
ConnectionDriverNameDefault: -
Description: The full class name of either the
JDBC java.sql.Driver, or a
javax.sql.DataSource implementation to use to connect to the
database. See for details.
openjpa.Connection2DriverName
Connection2DriverName
connections
Connection2DriverName
Property name:
openjpa.Connection2DriverNameConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getConnection2DriverName
Resource adaptor config-property:
Connection2DriverNameDefault: -
Description: This property is equivalent to the
openjpa.ConnectionDriverName property described in
, but applies to the
alternate connection factory used for unmanaged connections. See
for details.
openjpa.ConnectionFactory
ConnectionFactory
connections
ConnectionFactory
Property name:
openjpa.ConnectionFactoryConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionFactory
Resource adaptor config-property:
ConnectionFactoryDefault: -
Description: A javax.sql.DataSource
to use to connect to the database. See
for details.
openjpa.ConnectionFactory2
ConnectionFactory2
connections
ConnectionFactory2
Property name:
openjpa.ConnectionFactory2Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionFactory2
Resource adaptor config-property:
ConnectionFactory2Default: -
Description: An unmanaged
javax.sql.DataSource to use to connect to the database. See
for details.
openjpa.ConnectionFactoryName
ConnectionFactoryName
connections
ConnectionFactoryName
Property name:
openjpa.ConnectionFactoryNameConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionFactoryName
Resource adaptor config-property:
ConnectionFactoryNameDefault: -
Description: The JNDI location of a
javax.sql.DataSource to use to connect to the database. See
for details.
openjpa.ConnectionFactory2Name
ConnectionFactory2Name
connections
ConnectionFactory2Name
Property name:
openjpa.ConnectionFactory2NameConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionFactory2Name
Resource adaptor config-property:
ConnectionFactory2NameDefault: -
Description: The JNDI location of an unmanaged
javax.sql.DataSource to use to connect to the database.
See for details.
openjpa.ConnectionFactoryMode
ConnectionFactoryMode
connections
ConnectionFactoryMode
Property name:
openjpa.ConnectionFactoryModeConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionFactoryMode
Resource adaptor config-property:
ConnectionFactoryModeDefault: localPossible values: local,
managedDescription: The connection factory mode to use
when integrating with the application server's managed transactions. See
for details.
openjpa.ConnectionFactoryProperties
ConnectionFactoryProperties
connections
ConnectionFactoryProperties
Property name:
openjpa.ConnectionFactoryPropertiesConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionFactoryProperties
Resource adaptor config-property:
ConnectionFactoryPropertiesDefault: -
Description: A plugin string (see
) listing properties for
configuration of the datasource in use. See the
for details.
openjpa.ConnectionFactory2Properties
ConnectionFactory2Properties
connections
ConnectionFactory2Properties
Property name:
openjpa.ConnectionFactory2PropertiesConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionFactory2Properties
Resource adaptor config-property:
ConnectionFactory2PropertiesDefault: -
Description: This property is equivalent to the
openjpa.ConnectionFactoryProperties property described in
, but applies to the
alternate connection factory used for unmanaged connections. See
for details.
openjpa.ConnectionPassword
ConnectionPassword
connections
ConnectionPassword
Property name:
openjpa.ConnectionPasswordConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionPassword
Resource adaptor config-property:
ConnectionPasswordDefault: -
Description: The password for the user
specified in the ConnectionUserName property. See
for details.
openjpa.Connection2Password
Connection2Password
connections
Connection2Password
Property name:
openjpa.Connection2PasswordConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getConnection2Password
Resource adaptor config-property:
Connection2PasswordDefault: -
Description: This property is equivalent to the
openjpa.ConnectionPassword property described in
, but applies to the
alternate connection factory used for unmanaged connections. See
for details.
openjpa.ConnectionProperties
ConnectionProperties
connections
ConnectionProperties
Property name:
openjpa.ConnectionPropertiesConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionProperties
Resource adaptor config-property:
ConnectionPropertiesDefault: -
Description: A plugin string (see
) listing properties to configure
the driver listed in the ConnectionDriverName property
described below. See for details.
openjpa.Connection2Properties
Connection2Properties
connections
Connection2Properties
Property name:
openjpa.Connection2PropertiesConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getConnection2Properties
Resource adaptor config-property:
Connection2PropertiesDefault: -
Description: This property is equivalent to the
openjpa.ConnectionProperties property described in
, but applies to the
alternate connection factory used for unmanaged connections. See
for details.
openjpa.ConnectionURL
ConnectionURL
connections
ConnectionURL
Property name: openjpa.ConnectionURL
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionURL
Resource adaptor config-property:
ConnectionURLDefault: -
Description: The JDBC URL for the database. See
for details.
openjpa.Connection2URL
Connection2URL
connections
Connection2URL
Property name: openjpa.Connection2URL
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getConnection2URL
Resource adaptor config-property:
Connection2URLDefault: -
Description: This property is equivalent to the
openjpa.ConnectionURL property described in
, but applies to the alternate
connection factory used for unmanaged connections. See
for details.
openjpa.ConnectionUserName
ConnectionUserName
connections
ConnectionUserName
Property name:
openjpa.ConnectionUserNameConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionUserName
Resource adaptor config-property:
ConnectionUserNameDefault: -
Description: The user name to use when
connecting to the database. See the
for details.
openjpa.Connection2UserName
Connection2UserName
connections
Connection2UserName
Property name:
openjpa.Connection2UserNameConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getConnection2UserName
Resource adaptor config-property:
Connection2UserNameDefault: -
Description: This property is equivalent to the
openjpa.ConnectionUserName property described in
, but applies to the
alternate connection factory used for unmanaged connections. See
for details.
openjpa.ConnectionRetainMode
ConnectionRetainMode
connections
ConnectionRetainMode
Property name:
openjpa.ConnectionRetainModeConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getConnectionRetainMode
Resource adaptor config-property:
ConnectionRetainModeDefault: on-demandDescription: Controls how OpenJPA uses
datastore connections. This property can also be specified for individual
sessions. See for details.
openjpa.DataCache
DataCache
caching
DataCache
Property name: openjpa.DataCache
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getDataCache
Resource adaptor config-property:
DataCacheDefault: falseDescription: A plugin list string (see
) describing the
org.apache.openjpa.datacache.DataCaches to use for data
caching. See for details.
openjpa.DataCacheManager
DataCacheManager
caching
DataCacheManager
Property name:
openjpa.DataCacheManagerConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getDataCacheManager
Resource adaptor config-property:
DataCacheManagerDefault: defaultDescription: A plugin string (see
) describing the
openjpa.datacache.DataCacheManager that manages
the system data caches. See for details
on data caching.
openjpa.DataCacheMode
DataCacheMode
caching
DataCacheTimeout
Property name:
openjpa.DataCacheModeConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getDataCacheMode
Resource adaptor config-property:
DataCacheModeDefault: DataCacheMode.UNSPECIFIED (see javadoc for details)Description:Determines which entities will be included in the DataCache. May be any of the values defined in .
openjpa.DataCacheTimeout
DataCacheTimeout
caching
DataCacheTimeout
Property name:
openjpa.DataCacheTimeoutConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getDataCacheTimeout
Resource adaptor config-property:
DataCacheTimeoutDefault: -1Description: The number of milliseconds that
data in the data cache is valid. Set this to -1 to indicate that data should not
expire from the cache. This property can also be specified for individual
classes. See for details.
openjpa.DetachState
DetachState
detach
DetachState
DetachState
Property name: openjpa.DetachState
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getDetachState
Resource adaptor config-property:
DetachStateDefault: loadedPossible values: loaded,
fetch-groups, allDescription: Determines which fields are part
of the detached graph and related options. For more details, see
.
openjpa.DynamicDataStructs
DynamicDataStructs
caching
DynamicDataStructs
remote
DynamicDataStructs
Property name:
openjpa.DynamicDataStructsConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getDynamicDataStructs
Resource adaptor config-property:
DynamicDataStructsDefault: falseDescription: Whether to dynamically generate
customized structs to hold persistent data. Both the OpenJPA data cache and the
remote framework rely on data structs to cache and transfer persistent state.
With dynamic structs, OpenJPA can customize data storage for each class,
eliminating the need to generate primitive wrapper objects. This saves memory
and speeds up certain runtime operations. The price is a longer warm-up time for
the application - generating and loading custom classes into the JVM takes time.
Therefore, only set this property to true if you have a
long-running application where the initial cost of class generation is offset by
memory and speed optimization over time.
openjpa.FetchBatchSize
FetchBatchSize
large result sets
FetchBatchSize
Property name: openjpa.FetchBatchSize
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getFetchBatchSize
Resource adaptor config-property:
FetchBatchSizeDefault: -1Description: The number of rows to fetch at
once when scrolling through a result set. The fetch size can also be set at
runtime. See for details.
openjpa.EncryptionProvider
DataCache
encryption
Property name: openjpa.EncryptionProviderConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getEncryptionProviderResource adaptor config-property: EncryptionProviderDefault: falseDescription: A plugin list string (see
) describing the
org.apache.openjpa.lib.EncryptionProviders to use for connection password
encryption. See for details.
openjpa.FetchGroups
fetch groups
FetchGroups
Property name: openjpa.FetchGroups
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getFetchGroups
Resource adaptor config-property:
FetchGroupsDefault: -
Description: A comma-separated list of fetch
group names that are to be loaded when retrieving objects from the datastore.
Fetch groups can also be set at runtime. See
for details.
openjpa.FlushBeforeQueries
FlushBeforeQueries
Query
FlushBeforeQueries
flush
FlushBeforeQueries
Property name:
openjpa.FlushBeforeQueriesProperty name:
openjpa.FlushBeforeQueriesConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getFlushBeforeQueries
Resource adaptor config-property:
FlushBeforeQueriesDefault: trueDescription: Whether or not to flush any
changes made in the current transaction to the datastore before executing a
query. See for details.
openjpa.IgnoreChanges
IgnoreChanges
Property name: openjpa.IgnoreChanges
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getIgnoreChanges
Resource adaptor config-property:
IgnoreChangesDefault: falseDescription: Whether to consider modifications
to persistent objects made in the current transaction when evaluating queries.
Setting this to true allows OpenJPA to ignore changes and
execute the query directly against the datastore. A value of false
forces OpenJPA to consider whether the changes in the current
transaction affect the query, and if so to either evaluate the query in-memory
or flush before running it against the datastore.
openjpa.IdIdProperty name:openjpa.IdResource adaptor config-property:IdDefault: none
Description: An
environment-specific identifier for this configuration. This
might correspond to a JPA persistence-unit name, or to some other
more-unique value available in the current environment.
InitializeEagerly
openjpa.InitializeEagerly
InverseManager
Initialization
Configuration
Property name: openjpa.InitializeEagerly
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.isInitializeEagerly
Resource adaptor config-property:
InitializeEagerlyDefault: falsePossible values: false,
trueDescription: Controls whether initialization
is eager or lazy. Eager initialization imply all persistent classes, their
mapping information, database connectivity and all other resources specified in
the configuration of a persistence unit will be initialized when a persistent
unit is constructed. The default behavior is
lazy i.e. persistent classes, database and other resources are initialized only
when the application refers to a resource for the first time.
openjpa.InverseManager
InverseManager
bidirectional relation
InverseManager
Property name: openjpa.InverseManager
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getInverseManager
Resource adaptor config-property:
InverseManagerDefault: falsePossible values: false,
trueDescription: A plugin string (see
) describing a
org.apache.openjpa.kernel.InverseManager to use
for managing bidirectional relations upon a flush. See
for usage documentation.
openjpa.LockManager
LockManager
locking
LockManager
Property name: openjpa.LockManager
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getLockManager
Resource adaptor config-property:
LockManagerDefault: mixedPossible values: none,
sjvm, version,
pessimistic, mixedDescription: A plugin string (see
) describing a
org.apache.openjpa.kernel.LockManager to use for acquiring
locks on persistent instances during transactions. See
for more information.
openjpa.LockTimeout
LockTimeout
locking
LockTimeout
Property name: openjpa.LockTimeout
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getLockTimeout
Resource adaptor config-property:
LockTimeoutDefault: -1Description: The number of milliseconds to wait
for an object lock before throwing an exception, or -1 for no limit. See
for details.
openjpa.Log
Log
logging
Log
Property name: openjpa.LogConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getLogResource adaptor config-property: Log
Default: truePossible values: openjpa,
commons, log4j, noneDescription: A plugin string (see
) describing a
org.apache.openjpa.lib.log.LogFactory to use for logging.
For details on logging, see .
openjpa.ManagedRuntime
ManagedRuntime
transactions
managed
ManagedRuntime
Property name: openjpa.ManagedRuntime
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getManagedRuntime
Resource adaptor config-property:
ManagedRuntimeDefault: autoDescription: A plugin string (see
) describing the
org.apache.openjpa.ee.ManagedRuntime implementation to use
for obtaining a reference to the TransactionManager in an
enterprise environment.
openjpa.Mapping
Mapping
Property name: openjpa.Mapping
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getMappingResource adaptor config-property:
MappingDefault: -
Description: The symbolic name of the
object-to-datastore mapping to use.
openjpa.MaxFetchDepth
MaxFetchDepth
eager fetching
MaxFetchDepth
Property name: openjpa.MaxFetchDepth
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getMaxFetchDepth
Resource adaptor config-property:
MaxFetchDepthDefault: -1Description: The maximum depth of relations to
traverse when eager fetching. Use -1 for no limit. Defaults to no limit. See
for details on eager fetching.
openjpa.MetaDataFactory
MetaDataFactory
metadata
MetaDataFactory
Property name: openjpa.MetaDataFactory
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getMetaDataFactory
Resource adaptor config-property:
MetaDataFactoryDefault:jpaDescription: A plugin string (see
) describing the
openjpa.meta.MetaDataFactory to use to store and
retrieve metadata for your persistent classes. See
for details.
openjpa.Multithreaded
Multithreaded
threading
Multithreaded
Property name: openjpa.Multithreaded
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getMultithreaded
Resource adaptor config-property:
MultithreadedDefault: falseDescription: Whether persistent instances and
OpenJPA components other than the EntityManagerFactory
will be accessed by multiple threads at once.
openjpa.Optimistic
Optimistic
transactions
optimistic
Property name: openjpa.Optimistic
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getOptimistic
Resource adaptor config-property:
OptimisticDefault: trueDescription: Selects between optimistic and
pessimistic (datastore) transactional modes.
openjpa.OrphanedKeyAction
OrphanedKeyAction
foreign keys
OrphanedKeyAction
Property name:
openjpa.OrphanedKeyActionConfiguration API:org.apache.openjpa.conf.OpenJPAConfiguration.getOrphanedKeyAction
Resource adaptor config-property:
OrphanedKeyActionDefault: logPossible values: log,
exception, noneDescription: A plugin string (see
) describing a
org.apache.openjpa.event.OrphanedKeyAction to
invoke when OpenJPA discovers an orphaned datastore key. See
for details.
openjpa.NontransactionalRead
NontransactionalRead
Property name:
openjpa.NontransactionalReadConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getNontransactionalRead
Resource adaptor config-property:
NontransactionalReadDefault: trueDescription: Whether the OpenJPA runtime will
allow you to read data outside of a transaction.
openjpa.NontransactionalWrite
NontransactionalWrite
Property name:
openjpa.NontransactionalWriteConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getNontransactionalWrite
Resource adaptor config-property:
NontransactionalWriteDefault:trueDescription: Whether you can modify persistent
objects and perform persistence operations outside of a transaction. Changes
will take effect on the next transaction.
openjpa.ProxyManager
ProxyManager
proxies
ProxyManager
Property name: openjpa.ProxyManager
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getProxyManager
Resource adaptor config-property:
ProxyManagerDefault: defaultDescription: A plugin string (see
) describing a
org.apache.openjpa.util.ProxyManager to use for proxying
mutable second class objects. See
for details.
openjpa.QueryCache
QueryCache
caching
QueryCache
Property name: openjpa.QueryCache
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getQueryCache
Resource adaptor config-property:
QueryCacheDefault: true, when the data
cache (see ) is also enabled,
false otherwise.
Description: A plugin string (see
) describing the
org.apache.openjpa.datacache.QueryCache
implementation to use for caching of queries loaded from the data store. See
for details.
openjpa.QueryCompilationCache
QueryCompilationCache
caching
QueryCompilationCache
Property name:openjpa.QueryCompilationCacheResource adaptor config-property:QueryCompilationCacheDefault:true.
Description: A plugin string (see
) describing the
java.util.Map to use for caching of data used during
query compilation. See for details.
openjpa.ReadLockLevel
ReadLockLevel
locking
ReadLockLevel
Property name: openjpa.ReadLockLevel
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getReadLockLevel
Resource adaptor config-property:
ReadLockLevelDefault: readPossible values: none,
read, write,
optimistic, optimistic-force-increment,
pessimistic-read, pessimistic-write,
pessimistic-force-increment, numeric values for
lock-manager specific lock levels
Description: The default level at which to lock
objects retrieved during a non-optimistic transaction. Note that for the default
JDBC lock manager, read and write lock
levels are equivalent. Lock levels pessimistic-read,
pessimistic-write and
pessimistic-force-increment are in effect only when the
mixed lock manager is used.
openjpa.RemoteCommitProvider
RemoteCommitProvider
caching
RemoteCommitProvider
remote
RemoteCommitProvider
Property name:
openjpa.RemoteCommitProviderConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getRemoteCommitProvider
Resource adaptor config-property:
RemoteCommitProviderDefault: -
Description: A plugin string (see
) describing the
org.apache.openjpa.event.RemoteCommitProvider
implementation to use for distributed event notification. See
for more information.
openjpa.RestoreState
RestoreState
Property name: openjpa.RestoreState
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getRestoreState
Resource adaptor config-property:
RestoreStateDefault: nonePossible values: none,
immutable, allDescription: Whether to restore managed fields
to their pre-transaction values when a rollback occurs.
openjpa.RetainState
RetainState
Property name: openjpa.RetainState
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getRetainState
Resource adaptor config-property:
RetainStateDefault: trueDescription: Whether persistent fields retain
their values on transaction commit.
openjpa.RetryClassRegistration
RetryClassRegistration
metadata
RetryClassRegistration
Property name:
openjpa.RetryClassRegistrationConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getRetryClassRegistration
Resource adaptor config-property:
RetryClassRegistrationDefault: falseDescription: Controls whether to log a warning
and defer registration instead of throwing an exception when a persistent class
cannot be fully processed. This property should only be
used in complex classloader situations where security is preventing OpenJPA from
reading registered classes. Setting this to true unnecessarily may obscure more
serious problems.
openjpa.RuntimeUnenhancedClassesProperty name: openjpa.RuntimeUnenhancedClassesConfiguration API: org.apache.openjpa.conf.OpenJPAConfiguration.getRuntimeUnenhancedClassesResource adaptor config property:
RuntimeUnenhancedClasses
Default: unsupportedPossible values:supported,
unsupported,
warnDescription:
The RuntimeUnenhancedClasses property controls how OpenJPA
handles classes that have not been enhanced by the PCEnhancer
tool or automatically by a javaagent. If RuntimeUnenhancedClasses is
set to supported OpenJPA will automatically
create subclasses for unenhanced entity classes. If set to
unsupported OpenJPA will not create subclasses
for unenhanced entity classes and will throw an exception when
they are detected. If set to warn OpenJPA
will not create subclasses for unenhanced entity classes
but will log a warning message.
This function is often useful for rapid prototyping but is not
generally
recommended for use in production. Please consult the reference guide
before changing the default value.
See the reference guide section on unenhanced types for more
information
openjpa.DynamicEnhancementAgentProperty name: openjpa.DynamicEnhancementAgentConfiguration API: org.apache.openjpa.conf.OpenJPAConfiguration.getDynamicEnhancementAgentResource adaptor config property:
DynamicEnhancementAgent
Default: trueDescription:
The DynamicEnhancementAgent property controls whether or not
OpenJPA will attempt to dynamically load the PCEnhancer
javaagent.
See the reference guide for more information
openjpa.SavepointManager
Property name:
openjpa.SavepointManagerConfiguration API:
org.apache.openjpa.conf.OpenJPAConfiguration.getSavepointManagerResource adaptor config-property:
SavepointManager
Default: in-memPossible values: in-mem,
jdbc, oracleDescription: A plugin string (see
) describing a
org.apache.openjpa.kernel.SavepointManager to
use for managing transaction savepoints. See
for details.
openjpa.Sequence
Sequence
Property name: openjpa.Sequence
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getSequence
Resource adaptor config-property:
SequenceDefault: tableDescription: A plugin string (see
) describing the
org.apache.openjpa.kernel.Seq implementation to use for the
system sequence. See for more
information.
openjpa.Specification
Specification
Property name: openjpa.Specification
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getSpecificationInstance
Resource adaptor config-property:
SpecificationDefault: tableDescription: A formatted string describing the Specification
to use for the default configuration options. The format of the Specifcation string is
name [major.[minor]] where name denotes the name of the
Specification such as JPA or JDO, major
denotes the major integral version number of the Specification and minor
denotes a minor version which can be an arbitrary string.
See for more information.
openjpa.TransactionMode
TransactionMode
transactions
TransactionMode
Property name: openjpa.TransactionMode
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getTransactionMode
Resource adaptor config-property:
TransactionModeDefault: localPossible values: local,
managedDescription: The default transaction mode to
use. You can override this setting per-session.
openjpa.WriteLockLevel
WriteLockLevel
locking
WriteLockLevel
Property name: openjpa.WriteLockLevel
Configuration API:org.apache.openjpa.conf.OpenJPAConfiguration.getWriteLockLevel
Resource adaptor config-property:
WriteLockLevelDefault: writePossible values: none,
read, write,
optimistic, optimistic-force-increment,
pessimistic-read, pessimistic-write,
pessimistic-force-increment, numeric values for
lock-manager specific lock levels.
Description: The default level at which to lock
objects changed during a non-optimistic transaction. Note that for the default
JDBC lock manager, read and write lock
levels are equivalent. Lock levels pessimistic-read,
pessimistic-write and
pessimistic-force-increment are in effect only when the
mixed lock manager is used.
OpenJPA JDBC Properties
configuration
of JDBC properties
The following properties apply exclusively to the OpenJPA JDBC back-end.
openjpa.jdbc.ConnectionDecorators
ConnectionDecorators
connections
ConnectionDecorators
Property name:
openjpa.jdbc.ConnectionDecoratorsConfiguration API:
org.apache.openjpa.jdbc.conf.JDBCConfiguration.getConnectionDecorators
Resource adaptor config-property:
ConnectionDecoratorsDefault: -
Description: A comma-separated list of plugin
strings (see ) describing
org.apache.openjpa.lib.jdbc.ConnectionDecorator
instances to install on the connection factory. These decorators can wrap
connections passed from the underlying DataSource to add
functionality. OpenJPA will pass all connections through the list of decorators
before using them. Note that by default OpenJPA employs all
of the built-in decorators in the org.apache.openjpa.lib.jdbc
package already; you do not need to list them here.
openjpa.jdbc.DBDictionary
DBDictionary
JDBC
DBDictionary
Property name:
openjpa.jdbc.DBDictionaryConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getDBDictionary
Resource adaptor config-property:
DBDictionaryDefault: Based on the
openjpa.ConnectionURL
openjpa.ConnectionDriverNameDescription: A plugin string (see
) describing the
org.apache.openjpa.jdbc.sql.DBDictionary to use
for database interaction. OpenJPA typically auto-configures the dictionary based
on the JDBC URL, but you may have to set this property explicitly if you are
using an unrecognized driver, or to plug in your own dictionary for a database
OpenJPA does not support out-of-the-box. See
for details.
openjpa.jdbc.DriverDataSource
DriverDataSource
JDBC
DriverDataSource
Property name:
openjpa.jdbc.DriverDataSourceConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getDriverDataSource
Resource adaptor config-property:
DriverDataSourceDefault: poolingDescription: The alias or full class name of
the
org.apache.openjpa.jdbc.schema.DriverDataSource
implementation to use to wrap JDBC Driver classes with javax.sql.DataSource
instances.
openjpa.jdbc.EagerFetchMode
EagerFetchMode
eager fetching
EagerFetchMode
Property name:
openjpa.jdbc.EagerFetchModeConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getEagerFetchMode
Resource adaptor config-property:
EagerFetchModeDefault: parallelPossible values: parallel,
join, noneDescription: Optimizes how OpenJPA loads
persistent relations. This setting can also be varied at runtime. See
for details.
openjpa.jdbc.FetchDirection
FetchDirection
large result sets
FetchDirection
Property name:
openjpa.jdbc.FetchDirectionConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getFetchDirection
Resource adaptor config-property:
FetchDirectionDefault: forwardPossible values: forward,
reverse, unknownDescription: The expected order in which query
result lists will be accessed. This property can also be varied at runtime. See
for details.
openjpa.jdbc.JDBCListeners
JDBCListeners
JDBC
JDBCListeners
Property name:
openjpa.jdbc.JDBCListenersConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getJDBCListeners
Resource adaptor config-property:
JDBCListenersDefault: -
Description: A comma-separated list of plugin
strings (see ) describing
org.apache.openjpa.lib.jdbc.JDBCListener event
listeners to install. These listeners will be notified on various JDBC-related
events.
openjpa.jdbc.LRSSize
LRSSize
large result sets
LRSSize
Property name: openjpa.jdbc.LRSSize
Configuration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getLRSSize
Resource adaptor config-property:
LRSSizeDefault: queryPossible values: query,
last, unknownDescription: The strategy to use to calculate
the size of a result list. This property can also be varied at runtime. See
for details.
openjpa.jdbc.MappingDefaults
MappingDefaults
mapping metadata
MappingDefaults
Property name:
openjpa.jdbc.MappingDefaultsConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getMappingDefaults
Resource adaptor config-property:
MappingDefaultsDefault: jpa
Description: A plugin string (see
) describing the
org.apache.openjpa.jdbc.meta.MappingDefaults to
use to define default column names, table names, and constraints for your
persistent classes. See for
details.
openjpa.jdbc.MappingFactory
MappingFactory
mapping metadata
MappingFactory
Property name:
openjpa.jdbc.MappingFactoryConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getMappingFactory
Resource adaptor config-property:
MappingFactoryDefault: -
Description: A plugin string (see
) describing the
org.apache.openjpa.meta.MetaDataFactory to use to
store and retrieve object-relational mapping information for your persistent
classes. See for details.
openjpa.jdbc.QuerySQLCache
Prepared SQL Cache
caching
QuerySQLCache
Property name:openjpa.jdbc.QuerySQLCacheResource adaptor config-property:QuerySQLCacheDefault:true.
Description: A plugin string (see
) describing the options to cache and
reuse SQL statements generated for JPQL queries.
See for details.
openjpa.jdbc.ResultSetType
ResultSetType
large result sets
ResultSetType
Property name:
openjpa.jdbc.ResultSetTypeConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getResultSetType
Resource adaptor config-property:
ResultSetTypeDefault: forward-onlyPossible values: forward-only
, scroll-sensitive, scroll-insensitiveDescription: The JDBC result set type to use
when fetching result lists. This property can also be varied at runtime. See
for details.
openjpa.jdbc.Schema
schema
Schema
Property name: openjpa.jdbc.Schema
Configuration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getSchema
Resource adaptor config-property:
SchemaDefault: -
Description: The default schema name to prepend
to unqualified table names. Also, the schema in which OpenJPA will create new
tables. See for details.
openjpa.jdbc.SchemaFactory
SchemaFactory
schema
SchemaFactory
Property name:
openjpa.jdbc.SchemaFactoryConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getSchemaFactory
Resource adaptor config-property:
SchemaFactoryDefault: dynamicPossible values: dynamic,
native, file, table,
others
Description: A plugin string (see
) describing the
org.apache.openjpa.jdbc.schema.SchemaFactory to
use to store and retrieve information about the database schema. See
for details.
openjpa.jdbc.Schemas
schema
Schemas
Property name: openjpa.jdbc.Schemas
Configuration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getSchemas
Resource adaptor config-property:
SchemasDefault: -
Description: A comma-separated list of the
schemas and/or tables used for your persistent data. See
for details.
openjpa.jdbc.SQLFactory
SQLFactory
SQL
SQLFactory
Property name: openjpa.jdbc.SQLFactory
Configuration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getSQLFactory
Resource adaptor config-property:
SQLFactoryDefault: defaultDescription: A plugin string (see
) describing the
org.apache.openjpa.jdbc.sql.SQLFactory to use to abstract
common SQL constructs.
openjpa.jdbc.SubclassFetchMode
SubclassFetchMode
eager fetching
SubclassFetchMode
inheritance
SubclassFetchMode
Property name:
openjpa.jdbc.SubclassFetchModeConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getSubclassFetchMode
Resource adaptor config-property:
SubclassFetchModeDefault: parallelPossible values: parallel,
join, noneDescription: How to select subclass data when
it is in other tables. This setting can also be varied at runtime. See
.
openjpa.jdbc.SynchronizeMappings
SynchronizeMappings
mapping metadata
SynchronizeMappings
Property name:
openjpa.jdbc.SynchronizeMappingsConfiguration API:
org.apache.openjpa.jdbc.conf.JDBCConfiguration.getSynchronizeMappings
Resource adaptor config-property:
SynchronizeMappingsDefault: -
Description: Controls whether OpenJPA will
attempt to run the mapping tool on all persistent classes to synchronize their
mappings and schema at runtime. Useful for rapid test/debug cycles. See
for more information.
openjpa.jdbc.TransactionIsolation
TransactionIsolation
transactions
TransactionIsolation
JDBC
TransactionIsolation
Property name:
openjpa.jdbc.TransactionIsolationConfiguration API:
org.apache.openjpa.jdbc.conf.JDBCConfiguration.getTransactionIsolation
Resource adaptor config-property:
TransactionIsolationDefault: defaultPossible values: default,
none, read-committed,
read-uncommitted, repeatable-read,
serializableDescription: The JDBC transaction isolation
level to use. See for
details.
openjpa.jdbc.UpdateManager
UpdateManager
JDBC
UpdateManager
Property name:
openjpa.jdbc.UpdateManagerConfiguration API:org.apache.openjpa.jdbc.conf.JDBCConfiguration.getUpdateManager
Resource adaptor config-property:
UpdateManagerDefault: batching-constraintPossible values: default,
operation-order, constraint,
batching-constraint, batching-operation-orderDescription: The full class name of the
org.apache.openjpa.jdbc.kernel.UpdateManager to
use to flush persistent object changes to the datastore. The provided default
implementation is
org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.
Compatibility with Specification
The default behavior of certain OpenJPA API methods can evolve to align with the behaviors
defined in JPA specification. To maintain backward compatibility, OpenJPA allows configuration
options such that while the default behavior changes to align with current JPA Specification, the
previous behaviors can always be emulated.
For example, JPA 2.0 specification
introduces a new API void EntityManager.detach(Object entity) that detaches
the given entity from the current persistence context. OpenJPA has provided similar
feature via <T> T OpenJPAEntityManager.detach(T entity) prior to JPA 2.0.
OpenJPA detach(), however, has different default behavior than what JPA 2.0
specification mandates. Firstly, OpenJPA creates a copy of the given entity as a detached instance
and returns it, whereas JPA 2.0 behavior requires the same given entity instance be detached.
Secondly, the given instance is removed from the persistence context for JPA 2.0, whereas
OpenJPA detach() method, prior to JPA 2.0, does not remove the instance
from the persistence context as a copy is returned. Thirdly, OpenJPA will flush before
detaching a dirty instance so that the detached instance can later be merged, whereas
JPA 2.0 detach() semantics does not require a dirty instance be flushed
before detach.
A user application running with OpenJPA that is compliant to a specific version of JPA of specification,
the older behavior can be emulated by configuring OpenJPA Compatibility options.
For example, openjpa.Compatibility=FlushBeforeDetach=false,CopyOnDetach=true
will emulate the older behavior of detach even when running with OpenJPA that are
compliant to JPA 2.0 Specification. The configuration can also be set to a different version of the specification.
For example, openjpa.Specification="JPA 1.0" configuration setting will emulate
default OpenJPA behavior as it were for JPA Specification version 1.0. Setting via
openjpa.Specification is a shorthand for more fine-grained control available via
openjpa.Compatibility.