The ApplyChanges operation provides both delta and after-image
support for modifying or deleting a business object. The ApplyChanges
operation is available only if you use business graphs.
If you set the verb property of the business graph to the name
of an operation, such as create, update, or delete, the adapter performs
after-image processing for the ApplyChanges operation. For example,
if the verb is set to create, the adapter processes
the ApplyChanges operation the same as the Create operation.
If you do not set the verb in the business graph, the adapter uses
the ChangeSummary in the business graph to update the business object.
In this mode, the ApplyChanges operation differs from the Update operation
in the following ways:
- In the ApplyChanges operation, no Retrieve operation occurs before
updating.
- No comparisons are made between the incoming business object and
the business object in the database.
- All children are processed based on the operation set in the ChangeSummary
for each child business object. If a child does not have an operation
set in it, the adapter returns an error.
The adapter performs the following steps when updating a hierarchical
business object from the ChangeSummary. It processes only the changes
from the ChangeSummary.
- It recursively processes all single-cardinality children of the
parent object. If a child is marked required in the business object
specification, it must be present in the inbound object. If it is
not, the ApplyChanges operation fails, and the adapter returns an
error.
- It sets all foreign key values in the parent that reference attributes
in single-cardinality children to their corresponding child values. This
is necessary because single-cardinality children might have been added
to the database during the previous steps, resulting in the generation
of new sequence values.
- It updates the current object being processed using an SQL UPDATE
statement or a stored procedure. All simple attributes of the individual
business object are updated. The adapter does not use property level
changes to determine which attributes need to be added to the UPDATE
statement; they are all updated. Because the object being updated should
be unique, the adapter checks to ensure that only one row is processed
as a result. An error is returned if more than one row is processed.
- It sets all foreign key values in all cardinality N children of
the current object that reference parent attributes to the corresponding
parent values. Typically, these values are already cross-referenced
during data mapping; however, this might not be the case for new children
in cardinality N containers. This step ensures that the foreign key
values in all cardinality N children are correct before those children
are updated.
- It updates all cardinality N containers of the current object.
When
the child objects are processed, each child operation is taken, and
the appropriate operation is performed. The allowed operations on
a child in ApplyChanges are Create, Delete, and Update:
- If a Create operation is found in the child, the child is created
in the database if it is an ownership child. Non-ownership children
are retrieved to validate their existence in the database.
- If a Delete operation is found in the child, that child is deleted.
- If an Update operation is found in the child, the child is updated
in the database.