Migrating a CMP EJB project from WebLogic

When migrating a CMP EJB project from WebLogic you need to change the database schema name to NULLID, in order to made the generated code independent of the database schema name.

Limitation in specifying schema name

CMP EJB v1.x or v2.x mapping created against a data model using a specific schema name results in generated SQL code using the schema name prefix (schema_name.table). The database could be DB2® or Oracle or other vendor. This does not allow for flexibility when specifying a corresponding data source in WebSphere® Application Server or v7.x to be independent of the schema name in the generated code, by having the schema name to be automatically set to be the same as the login id used to connect to the database.

Flexible schema names

Rather than hard coding a schema name into a CMP EJB 1.x or 2.x mapping, use NULLID. If the schema name NULLID is used in the database model, then the generated EJB deploy code SQL statements are independent of the schema name, allowing flexibility in the data source specified on the WebSphere Application Server V7.x server. The NULLID prefix of the generated SQL statements (NULLID.table) is changed at runtime by the application server ejb/datasource runtime to correspond to the login id specified for the server data source.

If an EJB mapping is done against a database connection that results in a Data Model in the EJB backend folder in which the schema name is other than NULLID, you can change the schema name in this way:

  1. For Rational® Application Developer V7.0, there is a logical Data Models folder in an EJB project in the Enterprise Explorer view of the Java™ EE perspective. When expanded, the Data Models folder shows the database model file: {<name>).dbm. This file is physically located in the EJB project folder: ejbModule/META-INF/backends/{database vendor backend folder}.
  2. Double click the *.dbm data model file to open the Physical Data Model editor; or right click the file and select Open .
  3. Click the Schema, and its information will show in Properties view. Change the schema name to NULLID. Save the file.
  4. Right-click your CMP EJB project, and select Java EE > Prepare for deployment. The generated SQL code is prefixed with NULLID, and this prefix is modified at runtime by the WebSphere Application server to send SQL statements having a schema prefix corresponding to the login id
    Note: There are some database vendor and version scenarios where it is not acceptable to have the schema name correspond to the login id of the server data source and requires setting custom properties. For z/OS® DB2, see Specifying a runtime DB2 z/OS data source Schema for a CMP EJB Project with a NULLID mapped Schema.

Feedback