Adding/Deleting fields for Existing EJB
As requirements evolve during the course of a project, the
developer may find it necessary to adjust the existing data model. In most cases, this involves adding or
deleting a table column. Once the table
definition is changed, the developer must also update the corresponding
EJB. This is a common development task,
yet there is no tutorial or documentation in the WebSphere Commerce Infocenter.
A number of files are generated automatically when the EJB
is first created, so it’s not always clear which code should be updated. Follow
these steps when adding or deleting fields for existing EJB:
1. Take snapshot!
2. Modify deployment descriptor/bean class
3. Open bean class and add/delete CMP attribute
4. Demote ejbCreate from Home interface
5. Add/delete CMP attribute in ejbCreate and ejbPostCreate
argument list
6. Promote ejbCreate to Home interface
7. Modify _copyToEJB and _copyfromEJB methods to account for
added/removed field
8. Modify data definition:
WebSphereCommerceServerExtensionsData > ejbModule > META-INF >
backends > {databaseType} > MALL_NULLID_{tableName}.tblxmi. Add/delete
column from table definition.
9. Modify EJB to RDB mapping:
WebSphereCommerceServerExtensionsData > ejbModule > META-INF >
backends > {databaseType} > Map.mapxmi
If adding an EJB field, map the field to the table column.
If deleting a field, remove it from the mapping.
Note: The
field may already have been removed from the mapping when the deployment
descriptor and data definition were saved in the previous steps.
10. Deploy. If the
following error occurs, There are no enterprise beans in
WebSphereCommerceServerExtensionsData, delete all auto-generated files
(prefixed with the underscore), and deploy again.
Build.
11. Regenerate access bean.
We modify the _copy methods to ensure that all bean
references are updated. Without this
step, we found that the deployment descriptor sometimes reverted to the
original bean definition.
No comments:
Post a Comment