Managing child instances

The Activity Editor provides the function blocks in Table 81 to manage child object instances that belong to a parent in an identity relationship.

Table 81. Function blocks for Managing Child Instances
Function block Description
General/APIs/Identity Relationship/Add My Children Adds child relationship instances to parent/child relationship tables
General/APIs/Identity Relationship/Delete My Children Deletes child relationship instances to parent/child relationship tables
General/APIs/Identity Relationship/Update My Children Deletes or adds child relationship instances from parent/child relationship tables.

Note:
The most common use of the function blocks in Table 81 is to maintain child business objects in custom relationships involving composite identity relationships.

The function blocks in Table 81 assume that the parent business object being passed is an after-image; that is, the image of the business object after the verb operation has taken place. For example, if a business object has an Update verb with the update caused by the addition of new child objects, these new child objects already exist in the business object. Similarly, if a business object has an Update verb with the update caused by the deletion of child objects, the business object already has these child objects deleted.

This section provides the following information about how to manage child instances:

Creating the parent/child relationship definition

A parent/child relationship is a 1-to-many relationship between parent (1) and child (many) business objects. A parent/child relationship involves the following participants:

The relationship tables for a parent/child relationship enable the function blocks in Table 81 to track the child business objects associated with a particular parent business object.

To create a relationship definition for a parent/child relationship, take the following steps in Relationship Designer Express:

  1. Create a participant definition whose participant type is the parent business object.
  2. Set the participant attribute to the key of the parent business object.

    Expand the parent business object and select the key attribute.

  3. Create a participant definition whose participant type is the child business object.
  4. Set the participant attribute to the key of the child attribute.

    Expand the child business object (not the child attribute with the parent object) and select the key attribute from this child object.

Note:
The parent-child relationship needs to be maintained only if the child object does not have a unique key; that is, the child object only exists within the context of its parent.

For more information, see "Defining identity relationships".

Handling updates to the parent business object

This section provides the following steps to ensure that child objects that participate in a composite identity relationship are correctly managed during an Update:

Comparing the before- and after-images

The Update My Children function block updates the relationship tables for a parent/child relationship. A parent/child relationship is needed to help determine whether child objects have been added to or deleted from a parent business object.

For a given parent business object, this method makes sure that the following images of the business object match:

For the map to detect that a child business object has been deleted, it must determine how many instances of the child object of this type that the parent business object had before the Update (the before-image) and compare that to what the parent object presently has (the after-image). The map can use the Update My Children function block to make this comparison and find out what has been deleted or added.

When Update My Children compares the before- and after-images, it can determine whether to remove the associated relationship instances from the relationship tables for any child object that is not present in the parent business object. The method removed relationship instances from the following relationship tables:

Note:
Although Update My Children can also add instances to the relationship table for any child object that is present in the parent business object (but not in the child relationship table), it does not need to when called in the context of a composite identity relationship. All new child objects for the parent object have already been added to the relationship tables by the Maintain Composite Relationship function block For more information, see "Actions of General/APIs/Identity Relationship/Maintain Composite Relationship".

Tips on using Update My Children

When you use the Update My Children function block to maintain relationship tables for a child object involved in a composite identity relationship, keep the following tips in mind:

Copyright IBM Corp. 1997, 2003