Business Object Mediator
The Business Object Mediator (BOM) performs bidirectional transformations between the physical service data objects (SDO) and logical SDOs. By performing this role, it provides a business object persistence interface for the data service layer. The BOM supports create, read, update, delete operations on the logical SDOs so that the business logic layer can work with them rather than the physical schema.
In HCL Commerce Version 6, before Feature Pack 3, business logic deals with Enterprise Java™ Beans (EJB) directly. While these beans are relatively easy to manipulate, the drawback is that these beans are a direct mapping to the physical schema, which complicates extension and customization. Using EJB directly also ties the business logic to the persistence technology. As WebSphere® Commerce moves to SOA and continues to extend its support of Web service clients, a logical model of SDOs was defined for the business logic to use. The objects in this logical model, the logical SDOs, are the data interchange mechanism for inter-component interaction as well as Web service interactions.
There is also a set of service data objects used by the persistence layer, called physical SDOs. Physical SDOs are Java™ objects that represent the physical schema. The Business Object Mediator provides the mapping between these logical SDOs, and their counterparts in the persistence layer, the physical SDOs.
As part of the transformation process, the BOM uses the services of the Physical Data Container to fetch and save the physical data. The Physical Data Container manages the actual work of interacting with the physical schema. The Physical Data Container manages physical SDOs – it can create them, store arrays of them, and save them to the database.
As shown in the diagram above, there are two ways of persisting data through the data service layer. The most common approach is to call the BOM to transform your logical SDOs to physical SDOs. However, the business logic commands may occasionally need to work with physical objects directly, because they are not mapped to the logical model. For example, tables that are used to keep audit logs or statistics. In such cases, the business logic layer can make use the Physical Data Container to read and write data directly to the database.
Read and change mediators
The Data Service Layer initializes the BOM. These are classes that transform between the logical and physical representations of the domain model. This allows the business logic layer to deal only with the logical representation of the data. Each service module provides its own implementation for the mediators.
Each service module provides its own mediators, and there are two kinds: Read and Change mediators. They are listed in the Business Object Mediator configuration file. Read mediators are used to process the OAGIS Get requests. Change mediators handle the OAGIS Change, Process and Sync requests.
- Removing objects from the list of physical data objects within a mediator is not supported. That is, call the delete() method on the physical SDO directly to delete it.
- If you attempt to delete a parent DataObject after fetching the children of the DataObject in
the same data graph, the WebSphere Application Server JDBC mediator will throw an exception. You
have to delete the children DataObjects first before deleting the parent. However, if only the
parent DataObject is fetched in the graph when the parent data object is deleted, the entries in the
child table will be deleted by the database provided database table contains the constraint
ON DELETE CASCADE
.