ejb.isolationLevel

Specifies a global logical transaction isolation level for EJB-CMP entity beans in the module. This setting specifies the effective transaction isolation level for transactions managed using EAServer’s query caching and optimistic concurrency control (OCC) mechanisms. This setting allows the performance benefits of OCC and caching, while also enforcing an effective transaction isolation level as you would use with pessimistic concurrency control. For more information on configuring concurrency control mechanisms, see Chapter 4, “EJB CMP Tuning,” in the Performance and Tuning Guide.

The sql.isolationLevel Ant property specifies the database transaction isolation level used on the connection to the remote database.

To override this setting for individual components, create a <setProperties> command in your user configuration that runs the <persistentObject> subcommand. Specify the isolation level in the isolationLevel attribute. You can supply additional attributes to further tune the settings, for example the cacheTimeout attribute specifies a timeout for cached data.

Table 2-1 lists the allowable isolation levels.

Table 2-1: Logical isolation level values

Setting

Effect

ReadCache

Queries are satisfied by reading from the local query cache if possible. Otherwise, data is loaded from the remote database.

Not recommended, as use of this isolation level can result in “lost” updates: updates made from the entity bean may go through even if the data has been modified since first read from the database. If lost updates are unacceptable, use ReadCacheVerifyUpdates and verify that the concurrency control configuration allows for locking or OCC version control.

ReadCacheVerifyUpdates

Queries are satisfied by reading from the object cache if possible. Otherwise, data is loaded from the remote database. If the entity is changed or removed, the corresponding SQL update or delete verifies that the data was not changed after it was loaded from the DBMS.

This setting is suitable when it is acceptable for a read-only transaction to use stale cache data. To limit the use of stale data, specify a cache timeout by setting the cacheTimeout attribute for the <persistentObject> command, or by setting the cacheTimeout attribute for <queryMethod> commands.

ReadCommitted

Queries are satisfied by reading from the remote database. If the entity is changed or removed, the corresponding SQL update or delete does not verify that the data was not changed after it was loaded from the DBMS.

Not recommended, as use of this isolation level can result in “lost” updates. If lost updates are unacceptable, use ReadCommittedVerifyUpdates and verify that the concurrency control configuration allows for locking or OCC version control.

ReadCommittedVerifyUpdates

Queries are satisfied by reading from the remote database. If the entity is changed or removed, the corresponding SQL update or delete verifies that the data was not changed after it was loaded from the DBMS.

This setting provides a good balance of data integrity and performance. However, for some application data models, the maintenance of full data integrity requires a higher isolation level such as RepeatableRead.

ReadCommittedVerifyUpdatesWithCache may provide better performance.

ReadCommittedWithCache

Queries are satisfied by reading from the object cache if possible. Otherwise, data is loaded from the remote database. If the entity is changed or removed, the corresponding SQL update or delete does not verify that the data was not changed after it was loaded from the DBMS. Otherwise, for read-only access, and only if data was loaded from the local cache, a commit-time verify step ensures that the data has not changed since it was originally loaded from the DBMS. This ensures that any cached data that was used is still current at commit time, but does not prevent concurrent or conflicting updates.

This setting is not recommended, as it can result in lost updates. Instead, use ReadCommittedVerifyUpdatesWithCache.

ReadCommittedVerifyUpdates WithCache

Queries are satisfied by reading from the local cache if possible. Otherwise data is loaded from the remote database. If the entity is changed or removed, the corresponding SQL update/delete verifies that the data was not changed after it was loaded from the DBMS. Otherwise, for read-only access, and only if data was loaded from the local cache, a commit-time verify step ensures that the data has not changed since it was originally loaded from the DBMS. This ensures that any cached data that was used is still current at commit time. This setting does not prevent concurrent updates but does prevent conflicting updates.

This setting is suitable when it is not acceptable for a read-only transaction to use stale data, and where commit-time verification is cheaper than satisfying queries from the DBMS; in particular, where a table timestamp is specified with the <persistentObject> tableVersion attribute, or where a JDBC/JIT driver wrapper is used (the JIT driver wrappers can batch verification statements together at commit-time).

RepeatableRead

Queries are satisfied by reading from the remote database. If the entity is changed or removed, the corresponding SQL update or delete will verify that the data was not changed after it was loaded from the DBMS. Otherwise, for read-only access, a commit-time verification ensures that the data has not changed since it was loaded from the DBMS.

If pessimistic locking is enabled with the <persistentObject> selectWithSharedLock or selectWithUpdateLock attribute, and is supported by the DBMS, verification is skipped as the shared/exclusive locks that are obtained at load time will prevent conflicting updates.

WARNING! Pessimistic locking may increase the occurrence of deadlock.

This setting is suitable for cases where uncontrolled concurrent updates may result in data integrity problems (even for read-only access).

RepeatableReadWithCache may provide better performance, although if many transactions are updating the same rows, pessimistic locking with no cache is probably preferable.

RepeatableReadWithCache

Queries are satisfied by reading from the local cache if possible. Otherwise, data is loaded from the remote database. If the entity is changed or removed, the corresponding SQL update or delete verifies that the data was not changed after it was loaded from the DBMS. Otherwise, for read-only access, a commit-time verification ensures that the data has not changed since it was originally loaded from the DBMS.

This setting is suitable for cases where uncontrolled concurrent updates may result in data integrity problems (even for read-only access), where it is not acceptable for a read-only transaction to use stale cache data, and where commit-time verification is cheaper than satisfying queries from the DBMS; in particular, where a table timestamp is specified with the <persistentObject> tableVersion attribute, or where a JDBC/JIT driver wrapper is used (the JIT driver wrappers can batch verification statements together at commit-time).

If many transactions from other sources are updating the same rows, you may get better performance using RepeatableRead with pessimistic locking.

Serializable

Like RepeatableRead, except guarantees that the set of rows satisfying the query cannot change before the current transaction completes.

NoteThis isolation level is not supported when using Oracle databases. Use RepeatableRead instead, or add additional application-level data version checking code.

SerializableWithCache

Like RepeatableReadWithCache, except guarantees that the set of rows satisfying the query cannot change before the current transaction completes.

NoteThis isolation level is not supported when using Oracle databases. Use RepeatableReadCache instead, or add additional application-level data version checking code.