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
    1. Open bean class and add/delete CMP attribute
    2. Demote ejbCreate from Home interface
    3. Add/delete CMP attribute in ejbCreate and ejbPostCreate argument list
    4. Promote ejbCreate to Home interface
    5. Modify _copyToEJB and _copyfromEJB methods to account for added/removed field
  3. Modify data definition:  WebSphereCommerceServerExtensionsData > ejbModule > META-INF > backends > {databaseType} > MALL_NULLID_{tableName}.tblxmi. Add/delete column from table definition.
  4. Modify EJB to RDB mapping:   WebSphereCommerceServerExtensionsData > ejbModule > META-INF > backends > {databaseType} > Map.mapxmi
    1. If adding an EJB field, map the field to the table column.
    2. 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.
  5. 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.
  6. Build.
  7. 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.

Tagged with →  

Contact

Phone
(877) 962-7478
Fax
(818) 702-9066

Connect

Testimonials

“Whatever business you are in, we can help you gain market share and generate more revenue by leveraging the power of the Internet.”

Teresa Zobrist, President & CEO of Zobrist Consulting Group, Inc.