Copying a nested data object to another data object destroys the reference on the source object

A data object, Father, contains another data object, Child. Inside a Java snippet or client application, the object containing Child is fetched and set on a substructure of data object, Mother. The reference to Child in data object Father disappears.

Reason

The reference to Child is moved from Father to Mother.

Resolution

When such a data transformation is performed in a Java snippet or client application, and you want to retain the reference in Father, copy the data object before it is assigned to another object. The following code snippet illustrates how to do this:
BOCopy copyService = (BOCopy)ServiceManager.INSTANCE.locateService
                      ("com/ibm/websphere/bo/BOCopy"); 
DataObject Child = Father.get("Child"); 
DataObject BCopy = copyService.copy(Child); 
Mother.set("Child", BCopy);

(c) Copyright IBM Corporation 2005, 2006.
This information center is powered by Eclipse technology (http://www.eclipse.org)