This chapter describes the persistence property extensions.You configure persistence units in the JPA persistence descriptor file: persistence.xml. EclipseLink includes many persistence property enhancements and extensions that can be configured in the persistence.xml file.
This chapter includes the following sections:
The following lists the EclipseLink persistence property (persistence.xml file) extensions, categorized by function:
EclipseLink includes the following persistence property extensions for weaving:
EclipseLink includes the following persistence property extensions for customizing descriptors and sessions:
EclipseLink includes the following persistence property extensions for validation.
EclipseLink includes the following persistence property extensions for caching:
EclipseLink includes the following persistence property extensions for mappings:
EclipseLink includes the following persistence property extensions for mappings:
EclipseLink includes the following persistence property extensions for configuring JDBC connections and connection pooling:
The following lists the EclipseLink persistence property (persitence.xml file) extensions, in alphabetical order:
Use the eclipselink.application-location property to specify the file system directory in which EclipseLink writes (outputs) DDL files.
Table 5-1 describes this persistence property's values.
You may set this option only if the value of eclipselink.ddl-generation.output-mode is sql-script or both.
Example 5-1 shows how to use this property in the persistence.xml file.
Example 5-1 Using application-location in persistence.xml
<property name="eclipselink.application-location" value="c:/YOURDIRECTORY/"/>
Example 5-2 shows how to use this property in a property map.
Use the eclipselink.cache.coordination.channel property to configure cache coordination for a clustered environment.
Table 5-2 describes this persistence property's values.
If multiple EclipseLink deployments reside on the same network, they should be in different channels.
Example 5-3 shows how to use this property in the persistence.xml file.
Example 5-3 Using application-location in persistence.xml
<property name="eclipselink.cache.coordination.channel" value="EmployeeChannel" />
Example 5-4 shows how to use this property in a property map.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.jms.factory property to configure the JMS topic connection factory name, when using JMS coordination for a clustered environment.
Table 5-3 describes this persistence property's values.
Use this property for JMS coordination (when eclipselink.cache.coordination.protocol = jms).
See Example 5-13 for information on how to use this property.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.jms.host property to configure the URL of the JMS server that hosts the topic, when using JMS coordination for a clustered environment.
Table 5-4 describes this persistence property's values.
Use this property for JMS coordination (when eclipselink.cache.coordination.protocol = jms). You must use a fully qualified URL.
See Example 5-13 for information on how to use this property.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.jms.reuse-topic-publisher property to specify if the JSM transport manager should cache a TopicPubliser and reuse it for all cache coordination publishing.
Table 5-5 describes this persistence property's values.
Use this property for JMS coordination (when eclipselink.cache.coordination.protocol = jms).
See Example 5-13 for information on how to use this property.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.jms.topic property to set the JMS topic name, when using JMS coordination for a clustered environment.
Table 5-6 describes this persistence property's values.
Use this property for JMS coordination (when eclipselink.cache.coordination.protocol = jms).
See Example 5-13 for information on how to use this property.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.jndi.initial-context-factory property to set the JNDI InitialContext factory, when using cache coordination for a clustered environment.
Table 5-7 describes this persistence property's values.
Example 5-5 shows how to use this property in the persistence.xml file.
Example 5-5 Using cache.coordination.jndi.initial-context-factory in persistence.xml.
<property name="eclipselink.cache.coordination.jndi.initial-context-factory" value="weblogic.jndi.WLInitialContextFactory/>
Example 5-6 shows how to use this property in a property map.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.jndi.password property to set the password for the cache.coordination.jndi.user, when using cache coordination for a clustered environment.
Table 5-8 describes this persistence property's values.
Table 5-8 Valid Values for cache.coordination.jndi.password
| Value | Description |
|---|---|
|
value |
Password for the cache.coordination.jndi.user. |
Example 5-7 shows how to use this propery in the persistence.xml file.
Example 5-7 Using cache.coordination.jndi.password in persistence.xml
<property name="eclipselink.cache.coordination.jndi.user" value="USERNAME"/> <property name="eclipselink.cache.coordination.jndi.password" value="PASSWORD"/>
Example 5-8 shows how to use this property in a property map.
Example 5-8 Using cache.coordination.jndi.password in a Property Map
import org.eclipse.persistence.config.PersistenceUnitProperties; propertyMap.put(PersistenceUnitProperties.CACHE_COORDINATION_JNDI_USER, "USERNAME"); propertyMap.put(PersistenceUnitProperties.CACHE_COORDINATION_JNDI_PASSWORD, "PASSWORD");
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.jndi.user property to set JNDI naming service user, when using cache coordination for a clustered environment.
Table 5-9 describes this persistence property's values.
See Example 5-13 for information on how to use this property.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.naming-service property to specify the naming service to use, when using cache coordination for a clustered environment.
Table 5-10 describes this persistence property's values.
Example 5-9 shows how to use this property in the persistence.xml file.
Example 5-9 Using cache.coordination.naming-service in persistence.xml
<property name="eclipselink.cache.coordination" value="true"/> <property name="eclipselink.cache.coordination.naming-service" value="jndi"/>
Example 5-10 shows how to use this property in a property map.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.propagate-asynchronously property to specify if the coordination broadcast should occur asynchronously with the committing thread.
The property configures cache coordination for a clustered environment. Set if the coordination broadcast should occur asynchronously with the committing thread. This means the coordination will be complete before the thread returns from the commit of the transaction.
Table 5-11 describes this persistence property's values.
JMS cache coordination is always asynchronous, regardless of this setting.
By default, RMI cache coordination is asynchronous. Use synchronous (eclipselink.cache.coordination.propagate-asynchronously = false) to ensure that all servers are updated before the request returns.
Example 5-11 shows how to use this property in the persistence.xml file.
Example 5-11 Using cache.coordination.propagate-asynchronously in persistence.xml
<property name="eclipselink.cache.coordination.propagate-asynchronously" value="false" />
Example 5-12 shows how to use this property in a property map.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.protocol property to specify the cache coordination protocol to use. Depending on the cache configuration for each descriptor, this will broadcast cache updates or inserts to the cluster to update or invalidate each session's cache.
Table 5-12 describes this persistence property's values.
Table 5-12 Valid Values for cache.coordination.protocol
| Value | Description |
|---|---|
|
|
Use Java Message Service (JMS) to broadcast changes. |
|
|
Use an EJB MessageDrivenBean to be used to broadcast changes. You must configure the MessageDrivenBean separately. |
|
|
Use Java Remote Method Invocation (RMI) to broadcast changes. |
|
|
Use RMI over the Internet Inter-Orb Protocol (IIOP) to broadcast changes. |
|
ClassName |
The name of a subclass implementation of the |
You must specify the cache.coordination.protocol for every persistence unit and session in the cluster.
Example 5-13 shows how configure JMS cache coordination in the persistence.xml file.
Example 5-13 Configuring JMS Cache Coordination in persistence.xml
<property name="eclipselink.cache.coordination.protocol" value="jms" /> <property name="eclipselink.cache.coordination.jms.topic" value="jms/EmployeeTopic" /> <property name="eclipselink.cache.coordination.jms.factory" value="jms/EmployeeTopicConnectionFactory" />
If your application is not running in a cluster, you must provide the URL:
<property name="eclipselink.cache.coordination.jms.host" value="t3://myserver:7001/" />
You can also include a username and password, if required, to access the server (for example, if on a separate domain):
<property name="eclipselink.cache.coordination.jndi.user" value="weblogic" /> <property name="eclipselink.cache.coordination.jndi.password" value="welcome1" />
Example 5-14 shows how to configure RMI cache coordination in the persistence.xml file.
Example 5-14 Configuring RMI Cache Coordination in persistence.xml
<property name="eclipselink.cache.coordination.protocol" value="rmi" />
If your application is not running in a cluster, you must provide the URL:
<property name="eclipselink.cache.coordination.rmi.url" value="t3://myserver:7001/" />
You can also include a username and password, if required, to access the server (for example, if on a separate domain):
<property name="eclipselink.cache.coordination.jndi.user" value="weblogic" /> <property name="eclipselink.cache.coordination.jndi.password" value="welcome1" />
By default, RMI cache coordination broadcasts are asynchronous. You can override this, if needed:
<property name="eclipselink.cache.coordination.propagate-asynchronously" value="false" />
If you have multiple applications on the same server or network, you can specify a separate cache coordination channel for each application:
<property name="eclipselink.cache.coordination.channel" value="EmployeeChannel" />
RMI cache coordination uses a multicast socket to allow servers to find each other. You can configure the multicast settings, if needed:
<property name="eclipselink.cache.coordination.rmi.announcement-delay" value="1000" /> <property name="eclipselink.cache.coordination.rmi.multicast-group" value="239.192.0.0" /> <property name="eclipselink.cache.coordination.rmi.multicast-group.port" value="3121" /> <property name="eclipselink.cache.coordination.packet-time-to-live" value="2" />
For more information, see:
cache.coordination.jms.reuse-topic-publisher"cache.coordination.jms.reuse-topic-publisher"
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.remove-connection-on-error property to specify if the connection should be removed if EclipseLink encounters a communication error when coordinating the cache.
Table 5-13 describes this persistence property's values.
Example 5-15 shows how to use this property in the persistence.xml file.
Example 5-15 Using cache.coordination.remove-connection-on-error in peristence.xml
<property name="eclipselink.cache.coordination.remove-connection-on-error" value="true"/>
Example 5-16 shows how to use this property in a property map.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.rmi.announcement-delay property to set the time (in milliseconds) to wait for announcements from other cluster members on startup.
Table 5-14 describes this persistence property's values.
Use this property for RMI coordination (when eclipselink.cache.coordination.protocol = rmi).
See Example 5-14 for information on how to use this property.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.rmi.multicast-group property to set the multicast socket group address (used to find other members of the cluster), when using cache coordination for a clustered environment.
Table 5-15 describes this persistence property's values.
Use this property for RMI coordination (when eclipselink.cache.coordination.protocol = rmi).
See Example 5-14 for information on how to use this property.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.rmi.multicast-group.port property to set the multicast socket group port (used to find other members of the cluster), when using cache coordination for a clustered environment.
Table 5-16 describes this persistence property's values.
Use this property for RMI coordination (when eclipselink.cache.coordination.protocol = rmi).
See Example 5-14 for information on how to use this property.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.rmi.packet-time-to-live property to set the number of hops the session announcement data packets will take before expiring. The multicast group is used to find other members of the cluster.
Table 5-17 describes this persistence property's values.
If sessions are hosted on different LANs that are part of WAN, the announcement sent by one session may not reach other sessions. In this case, consult your network administrator for the correct time-to-live value or test your network by increasing the value until each session receives announcement sent by others.
Use this property for RMI coordination (when eclipselink.cache.coordination.protocol = rmi).
See Example 5-14 for information on how to use this property.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.rmi.url property to set the URL of the host server. This is the URL that other cluster member use to connect to this host.
Table 5-18 describes this persistence property's values.
Use this property for RMI coordination (when eclipselink.cache.coordination.protocol = rmi).
This may not be required in a clustered environment where JNDI is replicated. You can also set the location as a System property or using a SessionCustomizer to avoid requiring a separate persistence.xml file per server.
See Example 5-14 for information on how to use this property.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.coordination.thread.pool.size property to configure the size of the thread pool, for cache coordination threads.
Table 5-19 describes this persistence property's values.
For RMI cache coordination, EclipseLink spawns one thread per node to send change notifications and one thread to listen for new node notifications.
For JMS cache coordination, EclipseLink spawns one thread to receive JMS change notification messages (unless MDB is used) and one thread to process the change notification (unless MDB is used).
Example 5-17 shows how to use this property in the persistence.xml file.
Example 5-17 Using cache.coordination.thread.pool.size in persistence.xml
<property name="eclipselink.cache.coordination.thread.pool.size" value="48"/>
Example 5-18 shows how to use this property in a property map.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.cache.database-event-listener property to integrate EclipseLink with a database event notification service, such as Oracle QCN/DCN (Query Change Notification/Database Change Notification).
Table 5-20 describes this persistence property's values.
Table 5-20 Valid Values for cache.database-event-listener
| Value | Description |
|---|---|
|
Class |
The name of a class that implements You can also use DCN and QCN for Oracle. |
You can use this property to allow the EclipseLink cache to be invalidated by database change events, triggers, or other services.
Example 5-19 shows how to use this property with Oracle DCN.
Example 5-19 Using cache.database-event-listener in persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
persistence_2_0.xsd"
version="2.0">
<persistence-unit name="acme" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.cache.database-event-listener" value=
"org.eclipse.persistence.platform.database.oracle.dcn.OracleChangeNotificationList
ener"/>
</properties>
</persistence-unit>
</persistence>
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
"Database Change Notification" in Oracle Fusion Middleware Configuring and Managing JDBC Data Sources for Oracle WebLogic Server
Use the eclipselink.cache.shared property prefix to indicate whether an entity's cache is shared (non-isolated).
Table 5-21 describes this persistence property prefix's values.
Form a property name by appending either a valid entity name or class name to class.shared, indicating that the property values apply only to a particular entity. As an alternative, you can append the default suffix to the cache.shared property prefix to form a property name that sets the default for all entities.
See Example 2-12 for information on how to use this property.
Use the eclipselink.cache.size property prefix to specify the cache size for a specific entity type.
Table 5-22 describes this persistence property prefix's values.
Form a property name by appending either a valid entity name or class name to cache.size, indicating that the property values apply only to a particular entity. As an alternative, you can append the default suffix to the cache.size property prefix, indicating that the property value applies to all entities.
For most cache types, the size is only the initial size, not a fixed or maximum size. For CacheType.SoftCache and CacheType.HardCache types, the size is the sub-cache size. The default cache size is 100 Bytes.
See Example 2-12 for information on how to use this property.
Use the eclipselink.cache.type property prefix to set the type of cache.
Table 5-23 describes this persistence property prefix's values
Table 5-23 Valid values for cache.type
| Value | Description |
|---|---|
|
|
Holds all objects in use by the application, and allows any unreferenced objects to be free for garbage collection. This cache type guarantees object identity and allows optimal garbage collection, but provides little caching benefit. |
|
|
Holds all objects read by the application, and allows any unreferenced objects to be free for garbage collection only when the JVM decides that memory is low. This cache type guarantees object identity, allows for garbage collection when memory is low, and provides optimal caching benefit. |
|
|
(Default)Holds all objects read by the application, and a fixed-size subcache of MRU objects using |
|
|
Holds all objects in use by the application, and a fixed-size subcache of MRU objects using normal |
|
|
Holds all objects read by the application. This cache type does not allow garbage collection. This guarantees object identity, allows no garbage collection, and provides complete caching benefit. WARNING: Use this cache type only for a fixed number of objects; otherwise, memory leakage will occur eventually. |
|
|
Does not cache any objects, and frees any unreferenced objects for garbage collection. This provides no object identity, allows complete garbage collection, and provides no caching benefit. WARNING: This cache type should normally not be used. Instead, disable the shared cache through |
Form a property name by appending a valid entity name or class name to cache.type, indicating that the property values apply only to a particular entity. As an alternative, you can append the default suffix to the cache.type prefix to form a property name that sets the default for all entities.
Valid values for cache.type properties are declared in the CacheType class. The default is SoftWeak.
If you do not want to cache entities, set the cache.shared property.
See Example 2-12 for information about how to use this property.
Use the eclipselink.classloader property to create an EntityMangerFactory in the property map to be passed to Persistence.createEntityManagerFactory.
Table 5-24 describes this persistence property's values.
This is a dynamic property that must be set at runtime, in the property map. You cannot configure this property in the persistence.xml file.
Example 5-20 shows how to use this property in a property map.
Use the eclipselink.composite-unit property to specify if the persistence unit is a composite persistence unit.
Table 5-25 describes this persistence property's values.
The property must be specified in persistence.xml of a composite persistence unit. The composite persistence unit must contain all persistence units found in JAR files specified by the persistence.xml file.
Note:
If this property is passed to thecreateEntityManagerFactory method or if it is set in system properties, it is ignored.)Example 5-21 shows how to use this property in the persistence.xml file.
Example 5-21 Using composite-unit in persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0">
<persistence-unit name="compositePu" transaction-type="JTA">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<jar-file>member1.jar</jar-file>
<jar-file>member2.jar</jar-file>
<properties>
<property name="eclipselink.composite-unit" value="true"/>
<property name="eclipselink.target-server" value="WebLogic_10"/>
</properties>
</persistence-unit>
</persistence>
For more information, see:
"Using Multiple Databases with a Composite Persistence Unit" in Solutions Guide for EclispeLink
Use the eclipselink.composite-unit.member property to specify if the persistence unit is a member composite persistence unit.
Table 5-26 describes this persistence property's values.
Setting this property to true indicates that the persistence unit has dependencies on other persistence units.
Note:
If this property is passed to thecreateEntityManagerFactory method or if it is set in system properties, it is ignored.)
If this property is true, you may still create EntityManagerFactory, but it cannot be connected. Any attempt to create an entity manger will cause an exception.
When executing a native query on a composite persistence unit, use composite-unit.member to specify the name of the composite member persistence unit on which to execute the query.
Example 5-22 shows how to use this property in the persistence.xml file.
Example 5-22 Using composite-unit.member in persistence.xml
Composite member persistence unit memberPu2 is defined in the member2.jar file. It has dependency on a class defined in member1.jar and cannot be used independently.
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd"
version="1.0">
<persistence-unit name="memberPu2">
<provider>
org.eclipse.persistence.jpa.PersistenceProvider
</provider>
<mapping-file>META-INF/advanced-entity-mappings2.xml</mapping-file>
<jta-data-source>jdbc/MySqlJtaDS</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.composite-unit.member" value="true"/>
<property name="eclipselink.target-database"
value="org.eclipse.persistence.platform.database.MySQLPlatform"/>
</properties>
</persistence-unit>
</persistence>
Use the eclipselink.composite-unit.properties property to configure the properties for persistence unit members.
Table 5-27 describes this persistence property's values.
Pass this property to createEntityManager method of a composite persistence unit to pass properties to its member persistence units.
Example 5-23 shows how to use this property in a property map
Example 5-23 Using composite-unit.properties in a Property Map
Map props1 = new HashMap();
props1.put("javax.persistence.jdbc.user", "user1");
props1.put("javax.persistence.jdbc.password", "password1");
props1.put("javax.persistence.jdbc.driver", "oracle.jdbc.OracleDriver");
props1.put("javax.persistence.jdbc.url", "jdbc:oracle:thin:@oracle_db_url:1521:db");
Map props2 = new HashMap();
props2.put("javax.persistence.jdbc.user", "user2");
props2.put("javax.persistence.jdbc.password", "password2");
props2.put("javax.persistence.jdbc.driver", "com.mysql.jdbc.Driver");
props2.put("javax.persistence.jdbc.url", " jdbc:mysql://my_sql_db_url:3306/user2");
Map memberProps = new HashMap();
memberProps.put("memberPu1", props1);
memberProps.put("memberPu2", props2);
Map props = new HashMap();
props.put("eclipselink.logging.level", "FINEST");
props.put("eclipselink.composite-unit.properties", memberProps);
EntityManagerFactory emf = Persistence.createEntityManagerFactory("compositePu", props);
Use the eclipselink.connection-pool property to configure the various connection pool properties.
Table 5-28 describes this persistence property's values.
Table 5-28 Valid Values for connection-pool
| Value | Description |
|---|---|
|
|
Starting (initial) number of connections. |
|
|
Minimum number of connections. |
|
|
Maximum number of connections. |
|
|
Amount of time (in milliseconds) to wait for a connection from the pool. |
|
|
URL of the JDBC for the connection. |
|
|
For read connection pools, indicates that read connections are shared across threads. |
|
|
JTA DataSource name to use for the connection, if different than the default. |
|
|
Non-JTA DataSource name to use for the connection, if different than the default. |
|
|
Username to use for this connection (if different than the default). |
|
|
Password of the |
Append the name of the connection pool and property to be configured. If connection pool is specified, EclipseLink configures the default (write) pool.
Example 5-24 shows how to use this property in the persistence.xml file.
Example 5-24 Using connection-pool in persistence.xml
<property name="eclipselink.connection-pool.default.initial" value="1" /> <property name="eclipselink.connection-pool.node2.min" value="16"/> <property name="eclipselink.connection-pool.node2.max" value="16"/> <property name="eclipselink.connection-pool.node2.url" value="jdbc:oracle:thin:@node2:1521:orcl"/>
For more information, see:
"Connection Pools" in Understanding EclipseLink
"Connection Pooling" in Solutions Guide for EclispeLink
Use the eclipselink.connection-pool.read property to configure a read connection pool for non-transaction read queries.
Table 5-29 describes this persistence property's values.
Table 5-29 Valid Values for connection-pool.read
| Value | Description |
|---|---|
|
|
Starting (initial) number of connection. |
|
|
Minimum number of connections. |
|
|
Maximum number of connections. |
|
|
Amount of time it takes to get connections from the pool. |
|
|
URL of the JDBC connection. |
|
|
For read connection pools, indicates that read connections are shared across threads. |
|
|
JTA DataSource name to use for the connection, if different than the default. |
|
|
Non-JTA DataSource name to use for the connection, if different than the default. |
|
|
Username to use for this connection (if different than the default). |
|
|
Password of the |
By default, EclipseLink does not use a separate read connection pool; the default pool is used for read queries.
Example 5-25 shows how to use this property in the persistence.xml file.
For more information, see:
"Connection Pools" in Understanding EclipseLink
"Connection Pooling" in Solutions Guide for EclispeLink
Use the eclipselink.connection-pool.sequence property to have the connection pool allocate generated IDs.
Table 5-30 describes this persistence property's values.
This is only required for TABLE sequencing. By default, EclipseLink does not use a separate sequence connection pool; the default pool is used for sequencing.
Example 5-26 shows how to use this property in the persistence.xml file.
For more information, see:
"Connection Pools" in Understanding EclipseLink
"Connection Pooling" in Solutions Guide for EclispeLink
Use the eclipselink.create-ddl-jdbc-file-name property to specify the name of the DDL file generated by EclipseLink that contains the SQL statements to create tables for JPA entities.
Table 5-31 describes this persistence property's values.
Table 5-31 Valid Values for create-ddl-jdbc-file-name
| Value | Description |
|---|---|
|
File name |
A file name valid for your operating system. You can prefix the file name with a file path if a concatenation of |
If eclipselink.ddl-generation is set to create-tables or drop-and-create-tables, EclipseLink writes this file to the location specified by eclipselink.application-location.
See Example 5-27 for information on how to use this property.
Use the eclipselink.ddl-generation property to specify how EclipseLink generates DDL (Data Definition Language) for the database schema (tables and constraints) on deployment
Table 5-32 describes this persistence property's values.
Table 5-32 Valid Values for ddl-generation
| Value | Description |
|---|---|
|
|
EclipseLink will attempt to execute a If the table already exists, EclipseLink will follow the default behavior of your specific database and JDBC driver combination (when a |
|
|
EclipseLink will attempt to create tables. If the table exists, EclipseLink will add any missing columns. |
|
|
EclipseLink will attempt to This is useful in development if the schema frequently changes or during testing when the existing data needs to be cleared. Note: Using |
|
|
(Default) No DDL generated; no schema generated. |
You can use create-or-extend-tables only when eclipselink.ddl-generation.output-mode = database.
If you are using persistence in a Java SE environment and would like to create the DDL files without creating tables, additionally define a Java system property INTERACT_WITH_DB and set its value to false.
DDL_GENERATION must be set in order for this property to take effect.
Example 5-27 shows how to use this property in the persistence.xml file.
Example 5-27 Using ddl-generation in persistence.xml
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/> <property name="eclipselink.create-ddl-jdbc-file-name" value="createDDL_ddlGeneration.jdbc"/> <property name="eclipselink.drop-ddl-jdbc-file-name" value="dropDDL_ddlGeneration.jdbc"/> <property name="eclipselink.ddl-generation.output-mode" value="both"/>
Example 5-28 shows how to use this property in a property map.
Example 5-28 Using ddl-generation in a Property Map
import org.eclipse.persistence.config.PersistenceUnitProperties; propertiesMap.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.DROP_AND_CREATE); propertiesMap.put(PersistenceUnitProperties.DDL_GENERATION_MODE, PersistenceUnitProperties.BOTH); propertiesMap.put(PersistenceUnitProperties.CREATE_JDBC_DDL_FILE, "create.sql");
For more information, see:
Use the eclipselink.ddl-generation.output-mode property to specify where EclipseLink generates and writes the DDL.
Table 5-33 describes this persistence property's values.
Table 5-33 Valid Values for ddl-generation.output-mode
| Value | Description |
|---|---|
|
|
DDL will be generated and written to both the database and a file.
|
|
|
(Default) DDL will be generated and written to the database only. |
|
|
DDL will be generated and written to a file only.
|
You can only use ddl-generation.output-mode if you use ddl-generation. Then, you can optimally set other properties.
See Example 5-27 for information on how to use this property.
For more information, see:
Use the eclipselink.ddl.table-creation-suffix property to append a string to generated CREATE Table statements.
Table 5-34 describes this property's values.
Example 5-29 shows how to use this property in the persistence.xml file.
Use the eclipselink.deploy-on-startup property to configure deployment on startup (at the creation of the EntityManagerFactory) instead of occurring the first time an EntityManager is created.
Table 5-35 describes this persistence property's values.
Table 5-35 Valid Values for delay-on-startup
| Value | Description |
|---|---|
|
|
Causes a persistence unit to be created when the EntityManager is created, usually during deployment to a Java EE container or servlet container. |
|
|
(Default) The persistence unit is not initialized until the first EntityManager is created, or until metadata is required from the EntityManagerFactory. |
Using true may increase startup time of a JavaEE server, but will avoid the first request from hanging as the persistence unit is deployed.
Example 5-30 shows how to use this property in the peristence.xml file.
Use the eclipselink.descriptor.customizer property as a prefix for a property to configure a DescriptorCustomizer. Use this class's customize method, which takes an org.eclipse.persistence.descriptors.ClassDescriptor, to programmatically access advanced EclipseLink descriptor and mapping API for the descriptor associated with the JPA entity.
Table 5-36 describes this persistence property's values.
Example 5-31 shows how to use this property in the peristence.xml file.
Example 5-31 Using descriptor.customizer in persistence.xml
<property name="eclipselink.descriptor.customizer.Order" value="acme.sessions.MyDesriptorCustomizer"/>
Example 5-32 shows how to use this property with a property map.
For more information, see:
Understanding EclipseLink
Section 8.1, "Entity" in the JPA Specification http://jcp.org/en/jsr/detail?id=220
Use the eclipselink.drop-ddl-jdbc-file-name property to specify the name of the DDL file generated by EclipseLink that contains the SQL statements to drop tables for JPA entities.
Table 5-37 describes this persistence property's values.
Table 5-37 Valid Values for drop-ddl-jdbc-file-name
| Value | Description |
|---|---|
|
File name |
A file name valid for your operating system. You can prefix the file name with a file path if a concatenation of |
If eclipselink.ddl-generation is set to create-tables, EclipseLink writes this file to the location specified by eclipselink.application-location.
See Example 5-27 for information on how to use this property.
Use the eclipselink.exception-handler property to specify the EclipseLink exception handler class: an exception handler class that implements the org.eclipse.persistence.exceptions.ExceptionHandler interface. The class must provide a default, no-argument constructor.
Table 5-38 describes this persistence property's values.
Example 5-33 shows how to use this property in the persistence.xml file.
Example 5-33 Using exception-handler in persistence.xml
<property name="eclipselink.exception-handler" value="my.package.MyExceptionHandler">
Example 5-34 shows how to use this extension in a property map.
For more information, see:
"Sessions" in Understanding EclipseLink
"Managing and Diagnosing Problems" in Solutions Guide for EclispeLink
Use the eclipselink.exclude-eclipselink-orm property to exclude an EclipseLink ORM mapping file for a specific persistence unit.
Table 5-39 describes this persistence property's values.
By default the first file found at the resource name: META-INF/eclipselink-orm.xml is processed and overrides configurations specified in annotations and standard mapping files.
Example 5-35 shows how to use this property in the persistence.xml file.
Use the eclipselink.flush-clear.cache property to specify the EclipseLink EntityManager cache behavior when a clear method follows the flush method.
Table 5-40 describes this persistence property's values.
Table 5-40 Valid Values for flush-clear.cache
| Value | Description |
|---|---|
|
|
EclipseLink drops the entire Although this is the fastest mode and uses the least memory, the shared cache may potentially contain stale data after performing the commit. |
|
|
(Default) EclipseLink drops the entire This mode is slower than |
|
|
EclipseLink drops objects the Although this mode leaves the shared cache in a perfect state after performing the commit, it is the least memory-efficient. In a very large transaction you may run out of memory. |
You can specify this property when creating an EntityManagerFactory (in the map passed to the createEntityManagerFactory method or in the persistence.xml file), or an EntityManager (in the map passed to the createEntityManager method).
Note that the latter overrides the former.
Example 5-36 shows how to use this property in the persistence.xml file.
Example 5-36 Using flush-clear.cache in persistence.xml
<property name="eclipselink.flush-clear.cache" value="Drop"/>
Example 5-37 shows how to use this extension in a property map.
For more information, see:
"Cache Coordination" in Understanding EclipseLink
"Scaling TopLink Applications in Clusters" in Solutions Guide for EclispeLink
Use the eclipselink.id-validation property to define which primary key components values are considered invalid.
Table 5-41 describes this persistence property's values.
Table 5-41 Valid Values for id-validation
| Value | Description |
|---|---|
|
|
|
|
|
EclipseLink performs no ID validation. |
|
|
|
|
|
|
Identity and sequencing (with shouldAlwaysOverrideExistingValue configured as true) will override any existing ID value.
Example 5-38 shows how to use this property in the persistence.xml file.
Use the eclipselink.jdbc.allow-native-sql-queries property to specify if user-defined (that is, native) SQL is allowed within a persistence unit.
Table 5-42 describes this persistence property's values.
Within a multitenant, use this option to minimize the potential impact of revealing multitenant information. By default, any persistence unit with a multitenant entity causes EclipseLink to set eclipselink.jdbc.allow-native-sql-queries as false.
Example 5-39 shows how to use this property in the persistence.xml file.
Use the eclipselink.jdbc.batch-writing property to configure batch writing to optimize transactions with multiple write functions.
Table 5-43 describes this persistence property's values.
Table 5-43 Valid Values for jdbc.batch-writing
| Value | Description |
|---|---|
|
|
Use JDBC batch writing. |
|
|
Do not use JDBC batch writing or the platform's native batch writing. |
|
|
Use the Oracle platform's native batch writing. In a property map, use Note: This requires an Oracle JDBC driver. |
|
|
A custom class that extends the |
|
|
(Default) Do not use batch writing (that is, turn it off). |
Batch writing allows multiple heterogeneous dynamic SQL statements to be sent to the database as a single execution, or multiple homogeneous parameterized SQL statements to be executed as a single batch execution.
Note:
Not all JDBC drivers or databases support batch writing.Use eclipselink.jdbc.batch-writing.size to specify the batch size.
Example 5-40 shows how to use this property in the persistence.xml file.
Example 5-40 Using jdbc.batch-writing in persistence.xml
<property name="eclipselink.jdbc.batch-writing" value="Oracle-JDBC"/>
Example 5-41 shows how to use this property in a property map.
For more information, see:
"Batch Writing" in Solutions Guide for EclispeLink
Use the eclipselink.jdbc.batch-writing.size property to configure the batch size used for batch writing.
Table 5-44 describes this persistence property's values.
Example 5-42 shows how to use this property in the persistence.xml file.
For more information, see:
"Batch Writing" in Solutions Guide for EclispeLink
Use the eclipselink.jdbc.cache-statements property to specify if JDBC statements should be cached.
Table 5-45 describes this persistence property's values.
You should use this property when using EclipseLink's internal connection pooling. See "connection-pool" for more information.
Example 5-43 shows how to use this property in the persistence.xml file.
Example 5-43 Using jdbc.cache-statements in persistence.xml
<property name="eclipselink.jdbc.cache-statements" value="false"/>
Example 5-44 shows how to use this property in a property map.
For more information, see:
"Batch Writing" in Solutions Guide for EclispeLink
Use the eclipselink.jdbc.cache-statements.size property to specify the number of statements held when using internal statement caching.
Table 5-46 describes this persistence property's values.
Example 5-45 shows how to use this property in the persistence.xml file.
Example 5-45 Using jdbc.cache-statements.size in persistence.xml
<property name="eclipselink.jdbc.cache-statements.size" value="100"/>
Example 5-46 shows how to use this property in a property map.
For more information, see:
"Batch Writing" in Solutions Guide for EclispeLink
Use the eclipselink.jdbc.connector property to define a custom connector to connect to the database.
Table 5-47 describes this persistence property's values.
You can use this property to connect to a non-standard connection pool, or provide customized details on how to obtain a connection.
This property is not required when using a DataSource or JDBC DriverManager.
Example 5-47 shows how to use this property in the persistence.xml file.
Use the eclipselink.jdbc.exclusive-connection.is-lazy property to specify if EclipseLink acquires write connections lazily.
Table 5-48 describes this persistence property's values.
Example 5-48 shows how to use this property in the persistence.xml file.
Example 5-48 Using jdbc.exclusive-connection.is-lazy in persistence.xml
<property name="eclipselink.jdbc.exclusive-connection.is-lazy" value="false"/>
Example 5-49 shows how to use this property in a property map.
Use the eclipselink.jdbc.exclusive-connection.mode property to specify when EclipseLink performs reads through the write connection.
Table 5-49 describes this persistence property's values.
Table 5-49 Valid Values for jdbc.exclusive-connection.mode
| Value | Description |
|---|---|
|
|
(Default) Create an isolated client session if some or all entities require isolated cache, otherwise create a client session. Notes:
|
|
|
Create an exclusive isolated client session if reading an isolated entity, otherwise raise an error. Notes:
|
|
|
Create an exclusive isolated client session if reading an isolated entity, otherwise create an exclusive client session. Note: EclipseLink keeps the connection exclusive for the lifetime of the owning |
You can set this property while creating either an EntityManagerFactory (either in the map passed to the createEntityManagerFactory method, or in the persistence.xml file), or an EntityManager (in the map passed to the createEntityManager method). Note that the latter overrides the former.
Example 5-50 shows how to use this property in the persistence.xml file.
Example 5-50 Using jdbc.exclusive-connection.mode in persitence.xml
property name="eclipselink.jdbc.exclusive-connection.mode" value="Always"/>
Example 5-51 shows how to use this property in a property map.
For more information, see:
"Isolated Client Sessions" in Understanding EclipseLink
"Connections" in Understanding EclipseLink
Use the eclipselink.jdbc.native-sql property to specify if EclipseLink uses generic SLQ or includes platform-specific (that is, "native") SQL statements.
Table 5-50 describes this persistence property's values.
When using platform-specific SQL (eclipselink.jdbc.native-sql = true), EclipseLink uses platform-specific SQL to customize join syntax, date operators, using sequencing, and so on.
Example 5-52 shows how to use this property in the persistence.xml file.
Example 5-52 Using jdbc.native-sql in persistence.xml
<property name="eclipselink.jdbc.native-sql" value="false"/>
Example 5-53 shows how to use this property in a property map.
Use the eclipselink.jdbc.property prefix to pass JDBC driver-specific connection properties to EclipseLink.
Example 5-54 shows how to use this property prefix in the persistence.xml file.
Use the eclipselink.jdbc.sql-cast property to specify if EclipseLink uses platform-specific (that is, "native") CAST SQL operations.
Note:
Normally, casting is not required. Using it may cause issues.Table 5-51 describes this persistence property's values.
Example 5-55 shows how to use this property in the persistence.xml file.
Use the eclipselink.jdbc.uppercase-columns property to force column names from the metadata to be uppercase.
Note:
This parameter has been replaced byjpql.parser, which ensures that both sides use uppercase for comparisons.Table 5-52 describes this persistence property's values.
When using native SQL queries, the JDBC metadata may return column names in lower case on some platforms. If the column names are uppercase in the mappings (default), they will not match. You should use this parameter to force all column names from the metadata to uppercase.
Example 5-56 shows how to use this parameter in the persistence.xml file.
For more information, see:
"Using TopLink with the Oracle Database" in Solutions Guide for EclispeLink
"Introduction to Data Access" in Understanding EclipseLink
Use the eclipselink.jpql.parser property to configure the JPQL parser parameters.
Table 5-53 describes this persistence property's values.
Table 5-53 Valid Values for jpql.parser
| Value | Description |
|---|---|
|
|
(Default) Current parser, starting with EclipseLink 2.4, that provides extended JPQL support. |
|
|
Old parser, used for backward compatibility (prior to EclipseLink 2.4). |
Use the eclipselink.jpa.uppercase-column-names property to specify JPA processing to uppercase all column name definitions (simulating case insensitivity).
Table 5-54 describes this persistence property's values.
Table 5-54 Valid Values for jpa.uppercase-column-names
| Value | Description |
|---|---|
|
|
JDBC metadata returned from the database is returned in uppercase, ensuring fields are the same case. Sets |
|
|
(Default) Does not return JDBC metadata in uppercase. |
Use this property to correct situations in which user-defined fields do not match the case returned by the database for native queries.
Example 5-57 shows how to use this property in the persistence.xml file.
For more information, see:
"Using TopLink with the Oracle Database" in Solutions Guide for EclispeLink
"Introduction to Data Access" in Understanding EclipseLink
Use the eclipselink.jpql.parser property to configure the JPQL parser validation level.
Table 5-55 describes this persistence property's values.
This parameter applies only when eclipselink.jpql.parser is HermesParser.
Example 5-58 shows how to use this property in the persistence.xml file.
Use the eclipselink.logging.connection property to specify if connections are logged.
Table 5-56 describes this persistence property's values.
Using this parameter means that all connections are logged and not masked by the application code.
Example 5-59 shows how to use this parameter in the persistence.xml file.
For more information, see:
"Configuring WebLogic Server to Expose TopLink Logging" in Solutions Guide for EclispeLink
Use the eclipselink.logging.exceptions property to specify if exceptions are logged when they are thrown, before returning the exception to the calling application.
Table 5-57 describes this persistence property's values.
Using this property ensures that all exceptions are logged and not masked by the application code.
Example 5-60 shows how to use this property in the peristence.xml file.
Example 5-60 Using logging.exceptions in persistence.xml file
<property name="eclipselink.logging.exceptions" value="false" />
Example 5-61 shows how to use this property in a property map.
For more information, see:
"Configuring WebLogic Server to Expose TopLink Logging" in Solutions Guide for EclispeLink
Use the eclipselink.logging.file property to specify a file location in which to output the log instead of the standard out.
Table 5-58 describes this persistence property's values.
Example 5-62 shows how to use this property in the peristence.xml file.
Example 5-62 Using logging.file in persistence.xml file
<property name="eclipselink.logging.file" value="C:\myout\" />
Example 5-63 shows how to use this property in a property map.
Use the eclipselink.logging.level property to specify a specific logging level and control the amount and detail that is emitted.
Table 5-59 describes this persistence property's values.
Table 5-59 Valid Values for logging.level
| Value | Description |
|---|---|
|
|
Disables logging. You may want to use |
|
|
Logs exceptions indicating that EclipseLink cannot continue, as well as any exceptions generated during login. This includes a stack trace. |
|
|
Logs exceptions that do not force EclipseLink to stop, including all exceptions not logged with |
|
|
(Default) Logs the login/logout per sever session, including the user name. After acquiring the session, detailed information is logged. |
|
|
Logs only login, JDBC connection, and database information. You may want to use this log level at deployment time. |
|
|
Logs all SQL. You may want to use this log level during debugging and testing, but not at production time. |
|
|
Similar to |
|
|
Similar to |
|
|
Logs at the same level as |
Example 5-64 shows how to use this property in the peristence.xml file.
Example 5-64 Using logging.level in persistence.xml file
<property name="eclipselink.logging.level" value="OFF" />
Example 5-65 shows how to use this property in a property map.
Use the eclipselink.logging.logger property to define the type of logger to use.
Table 5-60 describes this persistence property's values.
Table 5-60 Valid Values for logging.logger
| Value | Description |
|---|---|
|
Custom logger |
Fully qualified class name of a custom logger which implements |
|
|
Uses |
|
|
Integrates with the application server's logging. |
|
|
(Default) Uses EclipseLink's native logger, |
Example 5-66 shows how to use this parameter in the persistence.xml file.
Example 5-66 Using logging.logger in persistence.xml
<property name="eclipselink.logging.logger" value="JavaLogger"/>
Example 5-67 shows how to use this parameter in a property map.
Use the eclipselink.logging.parameters property to define if SQL bind parameters are included in exceptions and logs.
Note:
This parameter applies to bind parameters only. Parameters are always displayed when not using binding.Table 5-61 describes this persistence property's values.
By default, when using logging.level of FINE (or greater), SQL bind parameters are displayed. Use this parameter to override the default behavior.
Example 5-58 shows how to use this parameter in the persistence.xml file.
For more information, see:
"Configuring WebLogic Server to Expose TopLink Logging" in Solutions Guide for EclispeLink
Use the eclipselink.logging.session property to specify if EclipseLink should include a session identifier in each log message.
Table 5-62 describes this persistence property's values.
This setting is applicable to messages that require a database connection such as SQL and the transaction information to determine on which underlying session (if any) the message was sent.
Example 5-69 shows how to use this property in the peristence.xml file.
Example 5-69 Using logging.session in persistence.xml file
<property name="eclipselink.logging.session" value="false" />
Example 5-70 shows how to use this property in a property map.
For more information, see:
"Configuring WebLogic Server to Expose TopLink Logging" in Solutions Guide for EclispeLink
Use the eclipselink.logging.thread property to specify if EclipseLink should include a thread identifier in each log message.
Table 5-63 describes this persistence property's values.
You should use this property when running multi-threaded applications. EclipseLink will include a hashcode of the thread.
Example 5-71 shows how to use this property in the peristence.xml file.
Example 5-71 Using logging.thread in persistence.xml file
<property name="eclipselink.logging.thread" value="false" />
Example 5-72 shows how to use this property in a property map.
For more information, see:
"Configuring WebLogic Server to Expose TopLink Logging" in Solutions Guide for EclispeLink
Use the eclipselink.logging.timestamp property to specify if EclipseLink should include a timestamp in each log message.
Table 5-64 describes this persistence property's values.
Example 5-73 shows how to use this property in the peristence.xml file.
Example 5-73 Using logging.timestamp in persistence.xml file
<property name="eclipselink.logging.timestamp" value="false" />
Example 5-74 shows how to use this property in a property map.
For more information, see:
"Configuring WebLogic Server to Expose TopLink Logging" in Solutions Guide for EclispeLink
Use the eclipselink.metadata-source property to specify the MetadataSource implementation EclipseLink uses to read metadata.
Table 5-65 describes this persistence property's values.
Use this property with eclipselink.metadata-source.xml.file to access an external mapping file at a fixed URL for a persistence unit.
Example 5-75 shows how to use this property in the persistence.xml file.
For more information, see:
"Using an External Metadata Source" in Solutions Guide for EclispeLink
Use the eclipselink.metadata-source.properties.file property to specify the name of the metadata repository properties file to read from, using the classloader to find the resource.
Table 5-66 describes this persistence property's values.
Use this property with eclipselink.metadata-source when using an XML repository.
Example 5-76 shows how to use this property in the persistence.xml file.
For more information, see:
"Using an External Metadata Source" in Solutions Guide for EclispeLink
Use the eclipselink.metadata-source.send-refresh-command property with cache coordination for a clustered environment to control how EclipseLink sends RCM refresh metadata commands to the cluster.
Table 5-67 describes this persistence property's values.
Table 5-67 Valid Values for metadata-source.send-refresh-command
| Value | Description |
|---|---|
|
|
(Default) To propogate refresh commands to the cluster, you must configure RCM and use the |
|
|
Does not propagate refresh commands to the cluster. |
If cache coordination is configured and the session is deployed on startup, this property controls the sending of RCM refresh metadata commands to the cluster.
These commands will cause the remote instances to refresh their metadata.
Example 5-77 shows how to use this property in the persistence.xml file.
Example 5-77 Using metadata-source.send-refresh-command in persistence.xml
<property name="eclipselink.metadata-source-refresh-command" value="false"/>
Example 5-78 shows how to use this property in a property map.
For more information, see:
"Using an External Metadata Source" in Solutions Guide for EclispeLink
Use the eclipselink.metadata-repository.xml.file property to specify the name of the metadata repository XML file to read from, using the classloader to find the resource.
Table 5-68 describes this persistence property's values.
Use this property with the eclipselink.metadata-source property when using an XML repository.
Example 5-79 shows how to use this property in the persistence.xml file.
For more information, see:
"Using an External Metadata Source" in Solutions Guide for EclispeLink
Use the eclipselink.metadata-source.xml.url property to specify the location of an external mapping file.
Table 5-69 describes this persistence property's values.
The metadata-source property must be set to XML.
Example 5-75 shows how to use this property in the persistence.xml file.
For more information, see:
"Using an External Metadata Source" in Solutions Guide for EclispeLink
Use the eclipselink.multitenant.tenants-share-cache property to specify if multitenant entities will share the L2 cache.
Table 5-70 describes this persistence property's values.
WARNING:
When this setting is false, queries that use the cache may return data from other tenants when using the PROTECTED setting.
Example 5-81shows how to use this property in the persistence.xml file.
Example 5-81 Using multitenant.tenants-share-cache in persistence.xml
<property name="eclipselink.multitenant.tenants-share-cache" value="true" />
Example 5-82 shows how to use this property in a property map.
For more information, see:
"Using Multitenancy" in Solutions Guide for EclispeLink
Use the eclipselink.multitenant.shared-emf property to specify if multitenant entities will be used within a shared entity manager factory.
Table 5-71 describes this persistence property's values.
Example 5-83 shows how to use this property in the persistence.xml file.
For more information, see:
"Using Multitenancy" in Solutions Guide for EclispeLink
Use the eclipselink.nosql.connection-factory property to specify the JNDI name of a JCA ConnectionFactory or a JCA ConnectionFactory class name that connects to the NoSQL data-source.
Table 5-72 describes this persistence property's values.
This property allows the JCA ConnectionFactory to be used with a NoSql or EIS adapter for a NoSQL datasource (that is, a non-relationship datasource such as a legacy database, NoSQL database, XML database, transactional and messaging systems, or ERP systems).
Example 5-84 shows how to use this property in the persistence.xml file.
For more information, see:
"Using NoSQL Databases" in Understanding EclipseLink
"Using EclipseLink with Nonrelational Databases" in Solutions Guide for EclispeLink
Use the eclipselink.nosql.connection-spec property to specify an EISConnectionSpec class name that defines how to connect to the NoSQL datasource.
Table 5-73 describes this persistence property's values.
This property allows the JCA ConnectionFactory to be used with a NoSql or EIS adapter for a NoSQL datasource (that is, a non-relationship datasource such as a legacy database, NoSQL database, XML database, transactional and messaging systems, or ERP systems).
See Example 5-85 for information on how to use this property.
For more information, see:
"Using NoSQL Databases" in Understanding EclipseLink
"Using EclipseLink with Nonrelational Databases" in Solutions Guide for EclispeLink
Use the eclipselink.nosql.property property to set NoSQL-specific connection properties.
Table 5-74 describes this persistence property's values.
Example 5-85 shows how to use this property in the persistence.xml file.
Example 5-85 Using nosql.property in persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_2_0.xsd"
version="2.0">
<persistence-unit name="acme" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.target-database"
value="org.eclipse.persistence.nosql.adapters.mongo.MongoPlatform"/>
<property name="eclipselink.nosql.connection-spec"
value="org.eclipse.persistence.nosql.adapters.mongo.MongoConnectionSpec"/>
<property name="eclipselink.nosql.property.mongo.port" value="27017,
27017"/>
<property name="eclipselink.nosql.property.mongo.host" value="host1,
host2"/>
<property name="eclipselink.nosql.property.mongo.db" value="acme"/>
</properties>
</persistence-unit>
</persistence>
For more information, see:
"Using Non-SQL Databases" in Understanding EclipseLink
Use the eclipselink.oracle.proxy-type property to specify the proxy type to be passed to the OracleConnection.openProxySession method.
Table 5-75 describes this persistence property's values.
Table 5-75 Valid Values for oracle.proxy-type
| Value | Description |
|---|---|
|
|
This type uses a user name for authentication when creating a proxy connection. |
|
|
This type uses a distinguished name for authentication when creating a proxy connection. |
|
|
This type uses a digital certificate for authentication when creating a proxy connection. |
This property requires Oracle JDBC version 10.1.0.2 or later and eclipselink.target-database must be configured to use Oracle9 or later.
Typically, you should set this property into EntityManager, through a createEntityManager method or by using proprietary setProperties method on EntityManagerImpl. This causes EntityManager to use proxy connection for writing and reading inside transaction.
If proxy-type and the corresponding proxy property set into EntityManagerFactory, all connections created by the factory will be proxy connections.
Example 5-86 shows how to use the property with EntityManager.
Example 5-86 Using eclipselink.oracle.proxy-type with EntityManager
Map emProperties = new HashMap();
emProperties.put("eclipselink.oracle.proxy-type",
OracleConnection.PROXYTYPE_USER_NAME);
emProperties.put(OracleConnection.PROXY_USER_NAME, "john");
EntityManager em = emf.createEntityManager(emProperties);
With injection:
entityManager.setProperty(”eclipselink.oracle.proxy-type”, OracleConnection.PROXYTYPE_USER_NAME); entityManager.setProperty(OracleConnection.PROXY_USER_NAME, ”john”);
Use the eclipselink.orm.throw.exceptions property to specify if EclipseLink throws an exception or logs a warning when encountering a problem with any of the files in the <mapping-file> element of the persistence.xml file.
Table 5-76 describes this persistence property's values.
Example 5-87 shows how to use this property in the persistence.xml file.
Example 5-87 Using orm.throw.exceptions in persistence.xml
<property name="oracle.orm.throw.exceptions" value="false"/>
Example 5-88 shows how to use this property in a property map.
Use the orm.validate.schema property to override orm.xml schema validation from its default value of false.
Table 5-77 describes this persistence property's values.
Example 5-89 shows how to use this property in the persistence.xml file.
Example 5-89 Using orm.validate.schema in persistence.xml
<property name="eclipselink.orm.validate.schema" value="true"/>
Example 5-90 shows how to use this property in a property map.
Use the eclipselink.partitioning property to set the default PartitioningPolicy for a persistence unit. The value must be the name of an existing, defined PartitioningPolicy.
Table 5-78 describes this persistence property's values.
Use this property to partition data for a class across multiple difference databases or across a database cluster such as Oracle RAC. Partitioning may provide improved scalability by allowing multiple database machines to service requests.
If multiple partitions are used to process a single transaction, use JTA (Java Transcription API) for proper XA transaction support.
Example 5-91 shows how to use this property in the persistence.xml file.
Use the eclipselink.partitioning.callback property to integrate an external DataSource's affinity support, such as UCP.
Table 5-79 describes this persistence property's values.
Example 5-92 shows how to use this property in the persistence.xml file.
Example 5-92 Using partitioning.callback in persistence.xml
<property name="eclipselink.partitioning.callback" value="mypacakge.MyDataPartitioningCallback"/>
Example 5-93 shows how to use this property in a property map.
Use the eclipselink.persistence-context.close-on-commit property to specify if the EntityManager will be closed or not used after commit (not extended).
Table 5-80 describes this persistence property's values.
For a container-managed EntityManager and most managed applications, you normally set this property to false. This setting avoids additional performance overhead of resuming the persistence context after a commit() transaction.
The property set in persistence.xml or passed to createEntityManagerFactory affects all EntityManagers created by the factory. Alternatively, to apply the property to specific EntityManagers, pass it to createEntityManager method.
Example 5-94 shows how to use this property in the persistence.xml file.
Example 5-94 Using persistence-context.close-on-commit in persistence.xml
<property name="eclipselink.persistence-context.close-on-commit" value="true"/>
Example 5-95 shows how to use this property in a property map.
Use the eclipselink.persistence-context.commit-without-persist-rules property to specify if the EntityManager will search all managed objects and persist any related non-managed new objects that are found, ignoring any absence of CascadeType.PERSIST settings.
Table 5-81 describes this persistence property's values.
Table 5-81 Valid Values for persistence-context.commit-without-persist-rules
| Value | Description |
|---|---|
|
|
Cascades Entity life-cycle Persist operations to related entities and uses the |
|
|
(Default) Does not cascase Entitiy life-cycle Persist operations to related entities and does not use the |
Example 5-96 shows how to use this property in the persistence.xml file.
Example 5-96 Using persistence-context.commit-without-persist-rules in persistence.xml
<property name="eclipse.persistence-context.commit-without-persist-rules" value="true"/>
Example 5-97 shows how to use this property in a property map.
Use the eclipselink.persistence-context.flush-mode property to configure the EntityManager FlushMode to be set as a persistence property and specify when flushing occurs.
Table 5-82 describes this persistence property's values.
The property set in persistence.xml or passed to createEntityManagerFactory affects all EntityManagers created by the factory. To apply the property to specific EntityManagers pass it to the createEntityManager method.
Example 5-98 shows how to use this property in the persistence.xml file.
Example 5-98 Using persistence-context.flush-mode in persistence.xml
<property name="eclipselink.persistence-context.flush-mode" value="commit" />
Example 5-99 shows how to use this property in a property map.
For more information, see:
"Enhancing Performance" in Solutions Guide for EclispeLink
Use the eclipselink.persistence-context.persist-on-commit property to specify if the EntityManager searches all managed objects and persists any related non-managed new objects that are cascade persist. This can be used to avoid the cost of performing this search if persist is always used for new objects.
Table 5-83 describes this persistence property's values.
The property set in persistence.xml or passed to createEntityManagerFactory affects all EntityManagers created by the factory. To apply the property to specific EntityManagers pass it to createEntityManager method.
Example 5-100 shows how to use this property in the persistence.xml file.
Example 5-100 Using persistence-context.persist-on-commit in persistence.xml
<property name="eclipselink.persistence-context.persist-on-commit" value="false"/>
Example 5-101 show how to use this property in a property map.
Use the eclipselink.persistence-context.reference-mode property to specify if hard or soft (that is, weak) references are used within the Persistence Context.
Table 5-84 describes this persistence property's values.
Table 5-84 Valid Values for persistence-context.reference-mode
| Value | Description |
|---|---|
|
|
(Default) EclipseLink references all objects through hard references. These objects will not be available for garbage collection until the referencing artifact (such as the persistence context or unit of work) is released/cleared or closed. |
|
|
References to objects supporting active attribute change tracking (see "@ChangeTracking") will be held by weak references. That is, any object no longer referenced directly or indirectly will be available for garbage collection. When a change is made to a change-tracked object, that object is moved to a hard reference and will not be available for garbage collection until flushed. Note: Any changes that have not been flushed in these entities will be lost. New and removed objects, as well as objects that do not support active attribute change tracking, will also be held by hard references and will not be available for garbage collection. |
|
|
All objects, including non-change-tracked objects, are to be held by weak references. When a change is made to a change-tracked object (see "@ChangeTracking"), that object is moved to a hard reference and will not be available for garbage collection until flushed. However, any objects that do not support active attribute change tracking may be garbage collected before their changes are flushed to a database, which can potentially result in a loss of changes. New and removed objects will be held by hard references and will not be available for garbage collection. |
The property set in persistence.xml or passed to createEntityManagerFactory affects all EntityManagers created by the factory. To apply the property to specific EntityManagers pass it to createEntityManager method.
Example 5-102 shows how to use this property in a persistence.xml file.
Example 5-102 Using persistence-context.reference-mode in persistence.xml
<property name="eclipselink.persistence-context.reference-mode" value="FORCE_WEAK"/>
Example 5-103 shows how to use this property in a property map.
Use the eclipselink.persistenceunits property to specify the set of persistence unit names that will be processed when generating the canonical model. By default, EclipseLink uses all persistence units available in all persistence XML files.
Table 5-85 describes this persistence property's values.
Example 5-104 shows how to use this property in the persistence.xml file.
Use the eclipselink.persistencexml property to specify the full resource name in which to look for the persistence XML files. If omitted, EclipseLink uses the default location: META-INF/persistence.xml.
Note:
Currently, this property is used only for the canonical model generator.Table 5-86 describes this persistence property's values.
This property is only used by EclipseLink when it is locating the configuration file. When used within an EJB/Spring container in container-managed mode, the locating and reading of this file is done by the container and will not use this configuration.
If you want to change the default location, use persisencexml.default.
Example 5-105 shows how to use this property in the persistence.xml file.
For more information, see:"persisencexml.default"
Use the eclipselink.persistencexml.default property to specify the default resource location where the persistence.xml configuration file is located. The default location is META-INF/persistence.xml.
Table 5-87 describes this persistence property's values.
Example 5-106 shows how to use this property in a property map.
Use the eclipselink.profiler property to specify which performance profiler to use in order to capture runtime statistics.
Table 5-88 describes this persistence property's values.
Table 5-88 Valid Values for profiler
| Value | Description |
|---|---|
|
|
(Default) Do not use a performance profiler. |
|
|
Use EclipseLink performance monitor |
|
|
Use EclipseLink performance profiler ( |
|
|
Monitor query executions and cache hits ( This option provides a simple low-overhead means for measuring performance of query executions and cache hits. You may want to use this option for performance analysis in a complex system. |
|
|
Use |
|
Custom profiler |
Specify a custom profiler class name which implements |
Example 5-107 shows how to use this property in the persistence.xml file.
Example 5-107 Using profiler in persistence.xml
<property name="eclipselink.profiler" value="PerformanceProfiler"/>
Example 5-108 shows how to use this property in a property map.
Use the eclipselink.session.customizer property to specify a session customizer class that implements the org.eclipse.persistence.config.SessionCustomizer interface. The class must provide a default, no argument constructor.
Table 5-89 describes this persistence property's values.
You can use the customize method of the class (which takes an org.eclipse.persistence.sessions.Session) to programmatically access advanced EclipseLink session API. You can use the session customizer class to define multiple session event listeners.
Example 5-109 shows how to use this property in the persistence.xml file.
Example 5-109 Using session.customizer in persistence.xml
<property name="eclipselink.session.customizer" value="acme.sessions.MySessionCustomizer"/>
Example 5-110 shows how to use this property in a property map.
Use the eclipselink.session.include.descriptor.queries property to specify whether all descriptor named queries are copied to the session for use by the entity manager.
Table 5-90 describes this persistence property's values.
Example 5-111 shows how to use this property in the persistence.xml file.
Example 5-111 Using session.include.descriptor.queries in persistence.xml
<property name="eclipselink.session.include.descriptor.queries" value="true"/>
Example 5-112 shows how to use this property in a property map.
Use the eclipselink.session-event-listener property to specify a descriptor event listener to be added during bootstrapping.
Table 5-91 describes this persistence property's values.
To define multiple event listener, you can use a session.customizer class.
Example 5-113 shows how to use this property in a persistence.xml file.
Example 5-113 Using session-event-listener in persistence.xml
<property name="eclipselink.session-event-listener" value="mypackage.MyClass.class"/>
Example 5-113 shows how to use this property in a property map.
Use the eclipselink.session-name property to configure a unique name to use when storing the singleton server session within the SessionManager.
Table 5-92 describes this persistence property's values.
By default, EclipseLink generates a unique session name. You can provide a custom, unique, session name with this property.
When using a sessions-xml file, you must include this session name as the name of the session in the sessions-xml file.
Example 5-115 shows how to use this property in the persistence.xml file.
Example 5-115 Using session-name in persistence.xml
<property name="eclipselink.session-name" value="MySession"/>
Example 5-116 shows how to use this property in a property map.
Use the eclipselink.sessions-xml property to use a specified native sessions.xml configuration file (which references a project.xml file) to load configuration and mapping information instead of JPA annotations or EclipseLink XML (as shown in Figure 5-1).
Table 5-93 describes this persistence property's values.
You can use the eclipselink.sessions-xml property as an alternative to using annotations and deployment XML. With this property, EclipseLink builds an in-memory EclipseLink session and project based on this metadata (as shown in Figure 5-1). You can acquire a persistence manager and use it, having defined all entities and so on using only EclipseLink sessions.xml.
Figure 5-1 Using the eclipselink.sessions-xml Persistence Property

Example 5-117 shows how to use this property in a persistence.xml file.
Example 5-117 Using sessions-xml in the persistence.xml file
<property name="eclipselink.sessions-xml" value="mysession.xml"/>
Example 5-118 shows how to use this property in a property map.
Use the eclipselink.target-database property to specify the database to use, controlling custom operations and SQL generation for the specified database.
Table 5-94 describes this persistence property's values.
Table 5-94 Valid Values for target-database
| Value | Description |
|---|---|
|
Defined in the |
Specify your database:
|
If eclipselink.validation-only = true, you cannot use an Auto class name or short name.
Example 5-119 shows how to use this property in the persistence.xml file.
Example 5-119 Using target-database in persistence.xml
<property name="eclipselink.target-database" value="Oracle"/>
or
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.HSQLPlatform"/>
Example 5-120 shows how to use this property in a property map.
Use the eclipselink.target-server property to configure the ServerPlatform that will be used to enable integration with a host container.
Table 5-95 describes this persistence property's values.
Table 5-95 Valid Values for target-server
| Value | Description |
|---|---|
|
Defined in the |
Specify your application server:
|
In addition to the supplied values, you can specify a custom server platform by supply the full class name for the platform.
Specifying a name of the class implementing ExternalTransactionController sets CustomServerPlatform with this controller.
Example 5-121 shows how to use this property in a persistence.xml file.
Example 5-121 Using target-server in persistence.xml
<property name="eclipselink.target-server" value="OC4J_10_1_3"/>
Example 5-122 shows how to use this property in a property map.
Use the eclipselink.temporal.mutable property to configure the default for detecting changes to the temporal field (Date, Calendar).
Table 5-96 shows this persistence property's values.
By default, it is assumed that temporal fields are replaced, and the temporal object is not changed directly.
Example 5-123 shows how to use this property in the persistence.xml file.
Example 5-123 Using temporal.mutable in persistence.xml
<property name="eclipselink.temporal.mutable" value="true"/>
Example 5-124 shows how to use this property in a property map.
Use the eclipselink.tenant-id property to specify the default context property used to populate multitenant entities.
Table 5-97 describes this persistence property's values.
This is a default multitenant property that can be used on its own or with other properties defined by you. You are not obligated to use this property. You are free to specify your own.
Example 5-125 shows how to use this property in the persistence.xmlfile.
Example 5-125 Using tenant-id in persistence.xml
<property name="eclipselink.tenant-id" value="Oracle"/>
Example 5-126 shows how to use this property in a property map.
Use the eclipselink.transaction.join-existing property to force the persistence context to read through the JTA-managed ("write") connect
ion in case there is an active transaction.
Table 5-98 describes this persistence property's values.
The property set in persistence.xml or passed to createEntityManagerFactory affects all EntityManagers created by the factory. If the property set to true, objects read during transaction will not be placed into the shared cache unless they have been updated. Alternatively, to apply the property only to some EntityManagers, pass it to createEntityManager method.
Example 5-127 shows how to use this property in the persistence.xml file.
Example 5-127 Using transaction.join-existing in persistence.xml
<property name="eclipselink.transaction.join-existing" value="true"/>
Example 5-128 shows how to use this property in a property map.
The eclipselink.tuning property selects the type of tuner to use to configure the persistence unit.
Table 5-99 describes this persistence property's values.
Table 5-99 Valid Values for tuning
| Value | Description |
|---|---|
|
|
(Default) Uses the standard tuner and does not change any of the default configuration settings. |
|
|
Configures the persistence unit for debugging. This disables caching and several performance optimizations. The purpose is to provide a simplified development and debugging configuration. |
|
custom tuner |
Specifies the full class name of an implementation of the |
Use automated tuning to set multiple configuration properties as part of a single flag to perform dynamic tuning during different steps of application deployment.
Example 5-129 shows how to use this property in the persistence.xml file.
Use the eclipselink.validate-existence property to specify if EclipseLink should verify an object's existence on persist().
Table 5-100 describes this persistence property's values.
Example 5-130 shows how to use this property in the persistence.xml file.
Example 5-130 Using validate-existence in persistence.xml
<property name="eclipselink.validate-existence" value="true"/>
Example 5-131 shows how to use this property in a proptery map.
Use the eclipselink.validation-only property to validate deployments by initializing descriptors but not connecting to the data source.
Table 5-101 describes this persistence property's values.
When setting eclipselink.validation-only to true, you must also configure eclipselink.target-database with a non-Auto class name or a short name.
Example 5-132 show how to use this property in the persistence.xml file.
Example 5-132 Using validation-only in persistence.xml
<property name="eclipselink.validation-only" value="true"/>
Example 5-133 shows how to use this property in a property map.
Use the eclipselink.weaving property to specify if EclipseLink weaves the entity classes. EclipseLink JPA uses weaving to enhance JPA entities for such things as lazy loading, change tracking, fetch groups, and internal optimizations.
Table 5-102 describes this persistence property's values.
Example 5-134 shows how to use this property in the persistence.xml file.
Example 5-135 shows how to use this property in a property map.
For more information, see:
"Using Weaving" in Understanding EclipseLink
"Enhancing Performance" in Solutions Guide for EclipseLink
Use the eclipselink.weaving.changetracking persistence property to:
Enable AttributeLevelChangeTracking through weaving.
Permit only classes with all mappings to change.
Permit tracking to enable change tracking. Mutable basic attributes prevent change tracking.
This property is enabled only when weaving is enabled.
Table 5-103 describes this persistence property's values.
Example 5-136 shows how to use this property in the persistence.xml file.
Example 5-136 Using weaving.changetracking in persistence.xml
<property name="eclipse.weaving.changetracking" value="false"/>
Example 5-137 shows how to use this property in a property map.
Use the eclipselink.weaving.eager property to specify if EclipseLink uses indirection on eager relationships.
Table 5-104 describes this persistence property's values.
One-to-one and many-to-one mappings, even when configured with FetchType.EAGER, will effectively become "lazy."
You can use this extension only if weaving is configured to true or static. See "weaving" for more information.
Example 5-138 shows how to use this property in the persistence.xml file.
Example 5-138 Using weaving in persistence.xml
<property name="eclipselink.weaving.eager" value="true"/>
Example 5-139 shows how to use this extension in a property map
Use the eclipselink.weaving.fetchgroups property to enable FetchGroups through weaving. When this is enabled, lazy direct mapping is supported, as well as descriptor and query-level FetchGroups.
FetchGroups allow partial objects to be read and written. Access to un-fetched attributes refreshes (fully-fetches) the object.
This property is only considered when weaving is enabled.
Table 5-105 describes this persistence property's values.
Example 5-140 shows how to use this property in the persistence.xml file.
Example 5-140 Using weaving.fetchgroups in persistence.xml
<property name="eclipselink.weaving.fetchgroups value="false"/>
Example 5-141 shows how to use this property in a property map.
Use the eclipselink.weaving.internal property to specify if EclipseLink uses internal optimizations through weaving.
Table 5-106 describes this persistence property's values.
You can use this extension only if weaving is configured to true or static. See "weaving" for more information.
Example 5-142 shows how to use this property in the persistence.xml file.
Example 5-142 Using weaving in persistence.xml
<property name="eclipselink.weaving.internal" value="false"/>
Example 5-143 shows how to use this property in a property map.
Use the eclipselink.weaving.lazy property to specify if EclipseLink uses lazy one-to-one and many-to-one mappings.
Table 5-107 describes this persistence property's values.
You can use this extension only if weaving is configured to true or static. See "weaving" for more information.
Example 5-144 shows how to use this property in the persistence.xml file.
Example 5-144 Using weaving.lazy in persistence.xml
<property name="eclipselink.weaving.lazy" value="false"/>
Example 5-145 shows how to use this property in a property map.