Top Description Fields Constructors Methods
org.eclipse.persistence.config

public final Class EntityManagerProperties

extends Object
Class Inheritance
Imports
java.util.HashSet, .Set, .Collections, jakarta.persistence.EntityManager

The class defines EclipseLink properties' names for use at the EntityManager level. This properties are specific to an EnityManger and should be passed to createEntityManager methods of EntityManagerFactory. Property values are usually case-insensitive with some common sense exceptions, for instance class names.

Field Summary

Modifier and TypeField and Description
public static final String
COMPOSITE_UNIT_PROPERTIES

The property may be passed to createEntityManager method of a composite persistence unit to pass properties to member persistence units.

public static final String
CONNECTION_POLICY

ConnectionPolicy Allows to specify an entire ConnectionPolicy.

public static final String
EXCLUSIVE_CONNECTION_IS_LAZY

Determines when write connection is acquired lazily.

public static final String
EXCLUSIVE_CONNECTION_MODE

Determines when reads are performed through the write connection.

public static final String
FLUSH_CLEAR_CACHE

Defines EntityManager cache behavior after a call to flush method followed by a call to clear method.

public static final String
JDBC_DRIVER

JDBC Driver class name.

public static final String
JDBC_PASSWORD

DataSource or JDBC DriverManager password.

public static final String
JDBC_URL

JDBC Connection String.

public static final String
JDBC_USER

DataSource or JDBC DriverManager user name.

public static final String
JOIN_EXISTING_TRANSACTION

Set to "true" this property forces persistence context to read through JTA-managed ("write") connection in case there is an active transaction.

public static final String
JTA_DATASOURCE

JTA DataSource.

public static final String
MULTITENANT_PROPERTY_DEFAULT

The "eclipselink.tenant-id" property specifies the default context property used to populate multitenant entities.

public static final String
MULTITENANT_SCHEMA_PROPERTY_DEFAULT

The "eclipselink.tenant-schema-id" property specifies the context property used to distinguish tenants when using global schema per tenant multitenant strategy.

public static final String
NON_JTA_DATASOURCE

NON JTA DataSource.

public static final String
ORACLE_PROXY_TYPE

This property is used to specify proxy type that should be passed to OarcleConnection.openProxySession method.

public static final String
ORDER_UPDATES

Configures if updates should be ordered by primary key.

public static final String
PERSISTENCE_CONTEXT_CLOSE_ON_COMMIT

Specifies that the EntityManager will be closed or not used after commit (not extended).

public static final String
PERSISTENCE_CONTEXT_COMMIT_ORDER

Defines the ordering of updates and deletes of a set of the same entity type during a commit or flush operation.

public static final String
PERSISTENCE_CONTEXT_COMMIT_WITHOUT_PERSIST_RULES

Specifies that 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.

public static final String
PERSISTENCE_CONTEXT_FLUSH_MODE

Allows the EntityManager FlushMode to be set as a persistence property.

public static final String
PERSISTENCE_CONTEXT_PERSIST_ON_COMMIT

Specifies that the EntityManager will search all managed objects and persist any related non-managed new objects that are cascade persist.

public static final String
PERSISTENCE_CONTEXT_REFERENCE_MODE

Specifies whether there should be hard or soft references used within the Persistence Context.

private static final Set<String>
public static final String
VALIDATE_EXISTENCE

Configures if the existence of an object should be verified on persist(), otherwise it will assume to be new if not in the persistence context.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Set<String>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COMPOSITE_UNIT_PROPERTIESback to summary
public static final String COMPOSITE_UNIT_PROPERTIES

The property may be passed to createEntityManager method of a composite persistence unit to pass properties to member persistence units. The value is a map: the key is a member persistence unit's name, the value is a map of properties to be passed to this persistence unit.

"eclipselink.composite-unit.properties" -> (
 ("memberPu1" -> (
   "jakarta.persistence.jdbc.user" -> "user1",
   "jakarta.persistence.jdbc.password" -> "password1",
   "jakarta.persistence.jdbc.driver" -> "oracle.jdbc.OracleDriver",
   "jakarta.persistence.jdbc.url" -> "jdbc:oracle:thin:@oracle_db_url:1521:db",
  ) ,
 ("memberPu2" -> (
   "jakarta.persistence.jdbc.user" -> "user2",
   "jakarta.persistence.jdbc.password" -> "password2"
   "jakarta.persistence.jdbc.driver" -> "com.mysql.jdbc.Driver",
   "jakarta.persistence.jdbc.url" -> "jdbc:mysql://my_sql_db_url:3306/user2",
  )
)

CONNECTION_POLICYback to summary
public static final String CONNECTION_POLICY

ConnectionPolicy Allows to specify an entire ConnectionPolicy. Note that in case any other ConnectionPolicy-altering properties are present they will be applied to this ConnectionPolicy. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

EXCLUSIVE_CONNECTION_IS_LAZYback to summary
public static final String EXCLUSIVE_CONNECTION_IS_LAZY

Determines when write connection is acquired lazily. Valid values are case-insensitive "false" and "true"; "true" is default. This property alters ConnectionPolicy. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

EXCLUSIVE_CONNECTION_MODEback to summary
public static final String EXCLUSIVE_CONNECTION_MODE

Determines when reads are performed through the write connection. This property alters ConnectionPolicy. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

See Also
ExclusiveConnectionMode
FLUSH_CLEAR_CACHEback to summary
public static final String FLUSH_CLEAR_CACHE

Defines EntityManager cache behavior after a call to flush method followed by a call to clear method. This property could be specified while creating either EntityManagerFactory (either in the map passed to createEntityManagerFactory method or in persistence.xml) or EntityManager (in the map passed to createEntityManager method); the latter overrides the former.

See Also
FlushClearCache
JDBC_DRIVERback to summary
public static final String JDBC_DRIVER

JDBC Driver class name. To avoid a conflict resulting in exception don't specify this property together with either JTA_DATASOURCE or JTA_DATASOURCE; however this property may override JTA_DATASOURCE or JTA_DATASOURCE specified in persistence.xml or in createEntityManagerFactory method. This property alters ConnectionPolicy. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

JDBC_PASSWORDback to summary
public static final String JDBC_PASSWORD

DataSource or JDBC DriverManager password. Non-empty value overrides the value assigned in persistence.xml or in createEntityManagerFactory; empty string value causes removal this property specified in persistence.xml or in createEntityManagerFactory method. This property alters ConnectionPolicy. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

JDBC_URLback to summary
public static final String JDBC_URL

JDBC Connection String. To avoid a conflict resulting in exception don't specify this property together with either JTA_DATASOURCE or JTA_DATASOURCE; however this property may override JTA_DATASOURCE or JTA_DATASOURCE specified in persistence.xml or in createEntityManagerFactory method. This property alters ConnectionPolicy. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

JDBC_USERback to summary
public static final String JDBC_USER

DataSource or JDBC DriverManager user name. Non-empty value overrides the value assigned in persistence.xml or in createEntityManagerFactory; empty string value causes removal this property and JDBC_PASSWORD property specified in persistence.xml or in createEntityManagerFactory method. This property alters ConnectionPolicy. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

JOIN_EXISTING_TRANSACTIONback to summary
public static final String JOIN_EXISTING_TRANSACTION

Set to "true" this property forces persistence context to read through JTA-managed ("write") connection in case there is an active transaction. Valid values are case-insensitive "false" and "true"; "false" is default. The property could also be set in persistence.xml or passed to createEntityManagerFactory, Note that if the property set to "true" then objects read during transaction won't be placed into the shared cache unless they have been updated. in that case it affects all EntityManagers created by the factory.

JTA_DATASOURCEback to summary
public static final String JTA_DATASOURCE

JTA DataSource. The value may be either data source or its name. Note that this property will be ignore in case persistence unit was setup to NOT use JTA: persistence.xml or createEntityManagerFactory had property "jakarta.persistence.transactionType" with RESOURCE_LOCAL value. To avoid a conflict resulting in exception don't specify this property together with either JDBC_DRIVER or JDBC_URL; however this property may override JDBC_DRIVER or JDBC_URL specified in persistence.xml or in createEntityManagerFactory method. This property alters ConnectionPolicy. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

MULTITENANT_PROPERTY_DEFAULTback to summary
public static final String MULTITENANT_PROPERTY_DEFAULT

The "eclipselink.tenant-id" property specifies the default context property used to populate multitenant entities.

Note

This is merely a default multitenant property than can be used on its own or with other properties defined by the user. Users are not obligated to use this property and are free to specify their own. Example: persistence.xml file <property name="eclipselink.tenant-id" value="Oracle"/> Example: property Map propertiesMap.put(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, "Oracle");

See Also
org.eclipse.persistence.annotations.Multitenant, org.eclipse.persistence.annotations.TenantDiscriminatorColumn
MULTITENANT_SCHEMA_PROPERTY_DEFAULTback to summary
public static final String MULTITENANT_SCHEMA_PROPERTY_DEFAULT

The "eclipselink.tenant-schema-id" property specifies the context property used to distinguish tenants when using global schema per tenant multitenant strategy. It is expected to be set by user when creating an EntityManager.

Java example:

props.put(PersistenceUnitProperties.MULTITENANT_SCHEMA_PROPERTY_DEFAULT, "Oracle");
See Also
PersistenceUnitProperties#MULTITENANT_STRATEGY, org.eclipse.persistence.descriptors.SchemaPerMultitenantPolicy
NON_JTA_DATASOURCEback to summary
public static final String NON_JTA_DATASOURCE

NON JTA DataSource. The value may be either data source or its name. Note that this property will be ignore in case persistence unit was setup to use JTA: persistence.xml or createEntityManagerFactory had property "jakarta.persistence.transactionType" with JTA value. To avoid a conflict resulting in exception don't specify this property together with either JDBC_DRIVER or JDBC_URL; however this property may override JDBC_DRIVER or JDBC_URL specified in persistence.xml or in createEntityManagerFactory method. This property alters ConnectionPolicy. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

ORACLE_PROXY_TYPEback to summary
public static final String ORACLE_PROXY_TYPE

This property is used to specify proxy type that should be passed to OarcleConnection.openProxySession method. Requires Oracle jdbc version 10.1.0.2 or later. Requires Oracle9Platform or later as a database platform (TARGET_DATABASE property value should be TargetDatabase.Oracle9 or later). The valid values are: OracleConnection.PROXYTYPE_USER_NAME, OracleConnection.PROXYTYPE_DISTINGUISHED_NAME, OracleConnection.PROXYTYPE_CERTIFICATE. Property property corresponding to the specified type should be also provided: OracleConnection.PROXY_USER_NAME, OracleConnection.PROXY_DISTINGUISHED_NAME, OracleConnection.PROXY_CERTIFICATE. Typically these properties should be set into EntityManager (either through createEntityManager method or using proprietary setProperties method on EntityManagerImpl) - that causes EntityManager to use proxy connection for writing and reading inside transaction. If proxy-type and the corresponding proxy property set into EntityManagerFactory then all connections created by the factory will be proxy connections. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

ORDER_UPDATESback to summary
public static final String ORDER_UPDATES

Deprecated

since 2.6 replaced by PERSISTENCE_CONTEXT_COMMIT_ORDER

Configures if updates should be ordered by primary key. This can be used to avoid possible database deadlocks from concurrent threads updating the same objects in different order. If not set to true, the order of updates is not guaranteed. "false" by default.

Annotations
@Deprecated
PERSISTENCE_CONTEXT_CLOSE_ON_COMMITback to summary
public static final String PERSISTENCE_CONTEXT_CLOSE_ON_COMMIT

Specifies that the EntityManager will be closed or not used after commit (not extended). In general this is normally always the case for a container managed EntityManager, and common for application managed. This can be used to avoid additional performance overhead of resuming the persistence context after a commit(). The property set in persistence.xml or passed to createEntityManagerFactory affects all EntityManagers created by the factory. Alternatively, to apply the property only to some EntityManagers pass it to createEntityManager method. Either "true" or "false. "false" is the default.

PERSISTENCE_CONTEXT_COMMIT_ORDERback to summary
public static final String PERSISTENCE_CONTEXT_COMMIT_ORDER

Defines the ordering of updates and deletes of a set of the same entity type during a commit or flush operation. The commit order of entities is defined by their foreign key constraints, and then sorted alphabetically.\

By default the commit of a set of the same entity type is ordered by its Id.

Entity type commit order can be modified using a DescriptorCustomizer and the ClassDescriptor.addConstraintDependency() API. Commit order can also be controlled using the EntityManager.flush() API.

Values (case insensitive):

  • "Id" (DEFAULT) : Updates and deletes are ordered by the object's id. This can help avoid deadlocks on highly concurrent systems.
  • "Changes": Updates are ordered by the object's changes, then by id. This can improve batch writing efficiency.
  • "None": No ordering is done.
See Also
CommitOrderType
PERSISTENCE_CONTEXT_COMMIT_WITHOUT_PERSIST_RULESback to summary
public static final String PERSISTENCE_CONTEXT_COMMIT_WITHOUT_PERSIST_RULES

Specifies that 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. Also the Entity lifecycle Persist operation will not be cascaded to related entities. This setting replicates the traditional EclipseLink native functionality.

PERSISTENCE_CONTEXT_FLUSH_MODEback to summary
public static final String PERSISTENCE_CONTEXT_FLUSH_MODE

Allows the EntityManager FlushMode to be set as a persistence property. This can be set to either "AUTO" or "COMMIT". By default the flush mode is AUTO, which requires an automatic flush before all query execution. This can be used to avoid any flushing until commit. The property set in persistence.xml or passed to createEntityManagerFactory affects all EntityManagers created by the factory. Alternatively, to apply the property only to some EntityManagers pass it to createEntityManager method.

See Also
jakarta.persistence.EntityManager#setFlushMode(jakarta.persistence.FlushModeType), jakarta.persistence.FlushModeType
PERSISTENCE_CONTEXT_PERSIST_ON_COMMITback to summary
public static final String PERSISTENCE_CONTEXT_PERSIST_ON_COMMIT

Specifies that the EntityManager will search all managed objects and persist 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. The property set in persistence.xml or passed to createEntityManagerFactory affects all EntityManagers created by the factory. Alternatively, to apply the property only to some EntityManagers pass it to createEntityManager method. Either "true" or "false. "true" is the default.

PERSISTENCE_CONTEXT_REFERENCE_MODEback to summary
public static final String PERSISTENCE_CONTEXT_REFERENCE_MODE

Specifies whether there should be hard or soft references used within the Persistence Context. Default is "HARD". With soft references entities no longer referenced by the application may be garbage collected freeing resources. Any changes that have not been flushed in these entities will be lost. The property could also be set in persistence.xml or passed to createEntityManagerFactory, in that case it affects all EntityManagers created by the factory. The property cannot be applied to existing active persistence unit context. The context could be removed by calling clear method on the EntityManager when there is no active transaction.

See Also
org.eclipse.persistence.config.ReferenceMode
supportedPropertiesback to summary
private static final Set<String> supportedProperties
VALIDATE_EXISTENCEback to summary
public static final String VALIDATE_EXISTENCE

Configures if the existence of an object should be verified on persist(), otherwise it will assume to be new if not in the persistence context. If checked and existing and not in the persistence context and error will be thrown. "false" by default.

Constructor Detail

EntityManagerPropertiesback to summary
private EntityManagerProperties()

Method Detail

getSupportedPropertiesback to summary
public static Set<String> getSupportedProperties()