Friday, 12 July 2019

Add/remove column fields for Existing EJB



Please find the below steps to make modifications for the existing data model like adding or deleting a table column.

  • Open bean class in Deployment descriptor and add/delete CMP attribute as per requirement.
  • Demote ejbCreate (In outline: Right click on ejbCreate and select Enterprise Bean -> select Demote from Home Interface)from bean.java file for the respective EJB.
  • Add/delete CMP attribute in ejbCreate and ejbPostCreate argument lists for the Bean.java file.
  • Now promote ejbCreate to Home interface
  • Modify _copyToEJB and _copyfromEJB methods to account for added/removed field
  • Modify data definition:  WebSphereCommerceServerExtensionsData > ejbModule > META-INF > backends > {databaseType} > MALL_NULLID_{tableName}.tblxmi. Add/delete column from table definition.
  • 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.
  • 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.
Once we are done with the above steps we can Build and regenerate the access bean.

Note: A number of files are generated automatically when the EJB is first created, so it’s not always clear which code should be updated and we modify the _copy methods to ensure that all bean references are updated.  Without the above steps, the deployment descriptor sometimes may revert to the original bean definition.

Java 7 Interview Question's

New Features introduced from  JAVA 7 : 1) Using strings in switch statements 2) Binary values with prefix 0B (Example: int n = 0b1101) 3) In...