Tutorials > Management Center > Create the Project BOD service module
Implement 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.
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's 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.
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.
WebSphere Commerce provides a tool called the Data Service Layer Wizard that automatically generates the Service Data Objects and object-relational metadata mentioned previously. The 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.
Procedure
- If the 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.
- Click File > New > Other > WebSphere Commerce > Data Service Layer .
- Click Next.
- Select the Work with a custom service module radio button, then click Next.
- Select the service module and and click Next:
- Service module: Select com.mycompany.commerce.project
If you do not see this service module, copy the com.mycompany.commerce.project from WCDE_INSTALL\workspace\Project-Server\sampleConfig\xml\config\ to WCDE_INSTALL\xml\config.
- Extension class prefix: Project
- Extension Java package name: com.mycompany.commerce.project
- Select all custom table names in the wizard:
- XPRJCATREL
- XPRJCOL
- XPRJCOLDES
- XPRJDES
- XPRJINS
- XPRJINSDES
- XPRJMTR
- XPRJMTRCATREL
- XPRJMTRDES
- XPRJPRJCOLREL
- XPROJECT
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.
- Click Next.
- If the WebSphere Commerce Developer environment uses an Oracle database, specify the data types manually, as the Oracle NUMBER data type can represent different number types. It can represent number types including integer, long, float, and double.
- Click Finish.
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's configuration folder under WC_EAR/xml/config/com.mycompany.commerce.project/wc-object-relational-metadata.xml.