Oracle Fusion Middleware Java API Reference for Oracle TopLink
11g Release 1 (11.1.1)


Class XMLCompositeCollectionMapping

  extended by oracle.toplink.mappings.DatabaseMapping
      extended by oracle.toplink.mappings.AggregateMapping
          extended by
              extended by oracle.toplink.ox.mappings.XMLCompositeCollectionMapping
All Implemented Interfaces:, java.lang.Cloneable, ContainerMapping, oracle.toplink.ox.mappings.XMLMapping

public class XMLCompositeCollectionMapping
extends AbstractCompositeCollectionMapping
implements oracle.toplink.ox.mappings.XMLMapping

Composite collection XML mappings map an attribute that contains a homogeneous collection of objects to multiple XML elements. Use composite collection XML mappings to represent one-to-many relationships. Composite collection XML mappings can reference any class that has a TopLink descriptor. The attribute in the object mapped must implement either the Java Collection interface (for example, Vector or HashSet) or Map interface (for example, Hashtable or TreeMap). The CompositeCollectionMapping class allows a reference to the mapped class and the indexing type for that class. This mapping is, by definition, privately owned.

Setting the XPath: TopLink XML mappings make use of XPath statements to find the relevant data in an XML document. The XPath statement is relative to the context node specified in the descriptor. The XPath may contain path and positional information; the last node in the XPath forms the local root node for the composite object. The XPath is specified on the mapping using the setXPath method.

The following XPath statements may be used to specify the location of XML data relating to an object's name attribute:

XPath Description
phone-number The phone number information is stored in the phone-number element.
contact-info/phone-number The XPath statement may be used to specify any valid path.
phone-number[2] The XPath statement may contain positional information. In this case the phone number information is stored in the second occurrence of the phone-number element.

Mapping a Composite Collection:

XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="">
  <xsd:element name="customer" type="customer-type"/>
  <xsd:complexType name="customer-type">
      <xsd:element name="first-name" type="xsd:string"/>
      <xsd:element name="last-name" type="xsd:string"/>
      <xsd:element name="phone-number">
            <xsd:element name="number" type="xsd:string"/>
          <xsd:attribute name="type" type="xsd:string"/>

Code Sample
XMLCompositeCollectionMapping phoneNumbersMapping = new XMLCompositeCollectionMapping();

More Information: For more information about using the XML Composite Collection Mapping, see the "Understanding XML Mappings" chapter of the Oracle TopLink Developer's Guide.

Oracle TopLink 10g Release 2 (10.1.3)
See Also:
Serialized Form

Constructor Summary
Method Summary
 ClassDescriptor getReferenceDescriptor(DOMRecord xmlRecord)
 java.lang.String getXPath()
          Get the XPath String
 void setXPath(java.lang.String xpathString)
          Set the Mapping field name attribute to the given XPath String
Methods inherited from class
getConverter, hasConverter, setContainerPolicy, setConverter, setField, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, useCollectionClass, useCollectionClassName, useListClassName, useMapClass, useMapClassName
Methods inherited from class oracle.toplink.mappings.AggregateMapping
getReferenceClass, setReferenceClass
Methods inherited from class oracle.toplink.mappings.DatabaseMapping
getAttributeAccessor, getAttributeClassification, getAttributeName, getGetMethodName, getProperty, getSetMethodName, isLazy, isOptional, isUsingMethodAccess, readOnly, readWrite, setAttributeAccessor, setAttributeName, setGetMethodName, setIsLazy, setIsOptional, setIsReadOnly, setProperty, setSetMethodName, setWeight
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public XMLCompositeCollectionMapping()
Method Detail


public java.lang.String getXPath()
Get the XPath String

String the XPath String associated with this Mapping *


public void setXPath(java.lang.String xpathString)
Set the Mapping field name attribute to the given XPath String

xpathString - String


public ClassDescriptor getReferenceDescriptor(DOMRecord xmlRecord)

Copyright © 1998, 2010, Oracle. All Rights Reserved.