Skip Headers

# Configuring CMP Information

Previous

Next

To configure CMP-specific information on a descriptor, define a `CMPPolicy`:

    descriptor.setCMPPolicy(new CMPPolicy());

You can use the following `CMPPolicy` API to configure optional behavior of enterprise beans:

Note: Most of these options are provided for compatibility with other CMP implementations. Use caution when using them as they will affect application performance.

- `setDeferModificationsUntilCommit`–By default TopLink defers all changes to the database until the transaction is committed. Use this method to configure TopLink to update the database after each EJB operation for the specified deferral level:

  - `CMPPolicy.NONE`–default behavior

  - `CMPPolicy.UPDATE_MODIFICATIONS`–update the database after each EJB operation for update modifications only

  - `CMPPolicy.ALL_MODIFICATIONS`–update the database after each EJB operation for all modifications

- `setNonDeferredCreateTime`–when using nondeferred writes (see setDeferModificationsUntilCommit), use this method to configure TopLink to insert a new enterprise bean before (`CMPPolicy.AFTER_EJBCREATE`) or after (`CMPPolicy.AFTER_EJBPOSTCREATE`) the `ejbPostCreate` method.

- `setForceUpdate`–use this method to make TopLink write all enterprise beans that have been accessed to the database regardless of whether they changed or not.

- `setUpdateAllFields`–use this method to configure TopLink to force all the fields of the bean to be updated instead of only the changed fields.

- `setPessimisticLockingPolicy`–use this method to configure EJB-level pessimistic locking.