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
- 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
- If your development environment uses an Apache Derby database, ensure that it does not have an existing connection by stopping the WebSphere Commerce Test Server.
- Click
- Expand WebSphere Commerce and select Data Service Layer.
- Click Next.
- Select the Work with a custom service module radio button, then click Next.
-
In the service module field, select com.mycompany.commerce.project.
Click Next. Use the following options:
- Service module: Select com.mycompany.commerce.project
- Extension class prefix: Project
- Extension Java package name: com.mycompany.commerce.project
Notes:- You might see a message that classes are being overwritten during this process. Select OK to overwrite these classes.
- If you do not see this service module, copy the com.mycompany.commerce.project from workspace_dir\Project-Server\sampleConfig\xml\config\ to WCDE_installdir\xml\config.
-
Select all custom table names in the wizard:
- XPRJCATREL
- XPRJCOL
- XPRJCOLDES
- XPRJDES
- XPRJINS
- XPRJINSDES
- XPRJMTR
- XPRJMTRCATREL
- XPRJMTRDES
- XPRJPRJCOLREL
- XPROJECT
Note: Only custom tables are selected. The project service module cannot access any other WebSphere Commerce table. WebSphere Commerce uses other service modules to access database tables that are provided by default. For example, the WebSphere Commerce catalog service is used to include catalog entry data in the project service. - Click Next.
- If 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.
- Click Finish.
Results
- 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.