Implementing the persistence layer for the WebSphere Commerce BOD programming model

The BOD programming model provides a Data Service Layer that is independent of the physical schema. In this lesson, you use the Data Service Layer wizard to generate the service data objects and object-relational metadata. The Data Service Layer wizard takes a list of the database tables as input and generates the object-relational mapping information and the static physical SDOs representing these tables.

About this task

Each service module, for example, Catalog and Marketing, has an independent data service implementation that contains the following assets:
  • Static physical Service Data Objects (SDO) that provide a Java representation of the service module view of the WebSphere Commerce schema. Each service module has a physical SDO for the tables that are read, updated, or deleted by the service module. For example, the catalog service module contains a physical SDO for the CATALOG table but the catalog service module does not contain a physical SDO for the ORDER table.
    Note: These physical SDOs are independent of the SDOs that are used to represent the logical model of a service module.
  • Object-relational metadata that maps a physical SDO to the actual physical table in the WebSphere Commerce schema.
  • Query templates that map WebSphere Commerce extended XPath notation expressions to one or more SQL template queries. These SQL template queries are used to retrieve the physical data from the database. This data is represented as physical SDOs.
  • A logical SDO (noun) to physical SDO mapping. For each logical SDO, this mapping defines the physical SDO that contains the unique ID of the noun.
  • Business object mediators that build logical SDOs from physical SDOs and physical SDOs from logical SDOs.
    • Read Mediators: Read mediators build a logical SDO out of the physical SDO using the defined mapping.
    • Change Mediators: Change mediators take a logical SDO as input and either create, update, or delete the appropriate physical SDOs. The modified physical SDOs are then saved back to the database.

Procedure

  1. Apache DerbyIf your development environment uses an Apache Derby database, ensure that it does not have an existing connection. For example, ensure that the WebSphere Commerce server is stopped.
  2. Click File > New > Other > WebSphere Commerce > Data Service Layer.
  3. Click Next.
  4. Select the Work with a custom service module radio button, then click Next.
  5. In the service module field, select com.mycompany.commerce.project; click Next:
    • Service module: Select com.mycompany.commerce.project
    • Extension class prefix: Project
    • Extension Java package name: com.mycompany.commerce.project
    Note: If you do not see this service module, copy the com.mycompany.commerce.project from WCDE_installdir\workspace\Project-Server\sampleConfig\xml\config\ to WCDE_installdir\xml\config.

    Screen capture that displays how to complete the Service Module Information page.
  6. Select all custom table names in the wizard:
    • XPRJCATREL
    • XPRJCOL
    • XPRJCOLDES
    • XPRJDES
    • XPRJINS
    • XPRJINSDES
    • XPRJMTR
    • XPRJMTRCATREL
    • XPRJMTRDES
    • XPRJPRJCOLREL
    • XPROJECT

    Screen capture that displays which custom tables to select for the Recipes tool.
    Note: Only custom tables are selected. The Project service module cannot access any other WebSphere Commerce table. Other service modules are used to access additional data. For example, the Catalog service is used to include Catalog Entry data in the Project service.
  7. Click Next.
  8. OracleIf your WebSphere Commerce Developer environment uses an Oracle database, you must specify the data types manually, as the Oracle NUMBER data type can represent different number types. It can represent number types such as integer, long, float, and double.
  9. Click Finish.

Results

Review the assets created by the Data Service Layer wizard. The following assets were generated:
  • The physical SDOs are generated in the Project-Server project under ejbModule/com.mycompany.commerce.project.facade.server.entity.datatypes. These SDOs provide a Java view of the database for the Project service.
  • An object-relational metadata file that describes the relationship between the physical SDOs and the database. This file is stored in the Project service module configuration folder under WC_eardir/xml/config/com.mycompany.commerce.project/wc-object-relational-metadata.xml.