Enabling optimistic locking
You can enable an optimistic concurrency control scheme for EJB 1.x CMP entity beans.
Concurrency control is the management of contention for data resources. A concurrency control scheme is considered pessimistic when it locks a given resource early in the data-access transaction and does not release it until the transaction is closed. A concurrency control scheme is considered optimistic when locks are acquired and released over a very short period of time at the end of a transaction.
The objective of optimistic concurrency is to minimize the time over which a given resource would be unavailable for use by other transactions. This is especially important with long-running transactions, which under a pessimistic scheme would lock up a resource for unacceptably long periods of time.
Under an optimistic scheme, locks are obtained immediately before a read operation and released immediately afterwards. Update locks are obtained immediately before an update operation and held until the end of the transaction.
For more information about optimistic locking and concurrency control, see the WebSphere Application Server documentation.
To enable optimistic locking for an EJB 1.x CMP entity bean:
- Switch to the J2EE perspective.
- In the Project Explorer view, right-click the desired EJB module, and select Open With > Deployment Descriptor Editor from the pop-up menu.
- On the Beans page of the editor, scroll to the Concurrency Control section.
- Select the Enable optimistic locking check box.