Migrating EJB projects to use optimistic locking
Use the optimistic locking migration plug-in to enable optimistic locking in an EJB project.
The optimistic locking plug-in can be used in the following scenarios:
- You are migrating to a new version of WebSphere Commerce. EJB projects developed to work with previous version of WebSphere Commerce that contain Container Managed Persistence (CMP) 1.x EJB beans need to be migrated to use WebSphere Commerce optimistic locking. Do this after migrating the EJB project to EJB 2.0 or 2.1.
- You created new entity beans and
want to enable optimistic locking in your new bean. Note: You can manually enable optimistic locking. See Creating new entity beans for more information.
About this task
ECEntityBean
class.
If the EJB entity bean class defines an ejbLoad
method,
that method must call super.ejbLoad
. If it defines
an ejbStore
method, that method must call super.ejbStore
.
Use the WebSphere Commerce optimistic locking validation plug-in for
IBM Rational Application Developer to check that the ejbLoad
and ejbStore
methods
of entity beans extend from ECEntityBean
or ECAbstractEntityBean
Procedure
- Open WebSphere Commerce Developer.
- Optional: Validating that CMP entity beans can use optimistic locking
- Expand the EJB Project that you want to migrate.
- For each ejbCreate method in each class in the project:
- Right-click the EJB Project that you want to migrate.
- Select Migrate to WC optimistic locking.
- When the migration is complete, click Details. A report of the files migrated displays. Check to see which files were changed, and whether any errors were found. If you need to store the migration results, you can select the results, right-click and select Copy and paste it into a text editor before clicking OK.
- Remember to re-deploy the EJB project for the changes to take effect.
Results
The optimistic locking plug-in changes the following files:
File Changed | File Type | Changes Made |
---|---|---|
ejb-jar.xml | EJB bean definitions | A new CMP field named "optCounter" is added, if it does not already exist, to all EJB 1.x entity beans whose primary key starts with "java.lang", or ends with "<class-name>Key", where <class-name> is the name of the EJB 1.x entity bean class. |
ibm-ejb-jar-ext.xmi | IBM WebSphere EJB bean extensions. | For each ejbExtensions element where xmi:type="ejbext:ContainerManagedEntityExtension", the plugin sets concurrencyControl="optimistic" and sets isolationLevel="READ_COMMITTED" on the isolationLevelAttributes element. |
Map.mapxmi | Mappings from EJB bean attribute definitions to database table schema column definitions | For EJB 1.x entity beans, the plugin creates a mapping with optimistic="true", if it doesn't already exist, from the "optCounter" CMP field to the "OPTCOUNTER" table schema column. |
When the plug-in detects that a change is
required to a file, it writes the information from the original file
in a file with the same name in the same directory but with an added
extension of ".orig". It then replaces the original file with the
migrated information. For example, the original information from the ejb-jar.xml
file
is written to a file named ejb-jar.xml.orig
, and
then the migrated information replaces the contents of the ejb-jar.xml
file.
You can use a file differencing tool to see the changes that were
made.