WebSphere Enterprise Service Bus for z/OS, Version 6.2.0 Operating Systems: z/OS


Single instance of a nested business object

Use the setWithCreate function to create a single instance of nested business object.

Before you begin

The example code below shows how you would normally have to create code for an intermediate (child) object from a higher level (parent) object in order to create a third-level (grandchild) object. The XSD file would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <xsd:complexType name="Parent">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string"/>
      <xsd:element name="child" type="Child"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="Child">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string"/>
      <xsd:element name="grandChild" type="GrandChild"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="GrandChild">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string"/>
    </xsd:sequence>
  </xsd:complexType>
  
</xsd:schema>

About this task

If you used the traditional "top-down" method to set the business object data, you would have to process the following code specifying the child and grandchild objects prior to setting the data in the grandchild object:
DataObject parent = ...
DataObject child = parent.createDataObject("child");
DataObject grandchild = child.createDataObject("grandChild");
grandchild.setString("name", "Bob");
You can use a more efficient method by using the setWithCreate function to simultaneously define the grandchild object and set its data, without having to specify the intermediate child object. The following example code shows how you would accomplish this task:
DataObject parent = ...
parent.setString("child/grandchild/name", "Bob");

Results

The lower-level business object data is set without having to reference the intermediate-level business object. An exception occurs if the path is not valid.


task Task topic

Terms of use | Feedback


Timestamp icon Last updated: 21 June 2010


http://publib.boulder.ibm.com/infocenter/dmndhelp/v6r2mx/topic//com.ibm.websphere.wesb620.zseries.doc/doc/cpro_singleinstance.html
Copyright IBM Corporation 2005, 2010. All Rights Reserved.
This information center is powered by Eclipse technology (http://www.eclipse.org).