Top Description Fields Constructors Methods
org.eclipse.persistence.oxm.mappings

public Class XMLCompositeCollectionMapping

extends AbstractCompositeCollectionMapping
implements CompositeCollectionMapping<AbstractSession, AttributeAccessor, ContainerPolicy, Converter, ClassDescriptor, DatabaseField, XMLMarshaller, Session, UnmarshalKeepAsElementPolicy, XMLUnmarshaller, XMLRecord>, XMLMapping, XMLNillableMapping
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.oxm.mappings.XMLNillableMapping, org.eclipse.persistence.oxm.mappings.XMLMapping, org.eclipse.persistence.internal.oxm.mappings.Mapping, org.eclipse.persistence.internal.oxm.mappings.CompositeCollectionMapping, org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping, org.eclipse.persistence.internal.oxm.mappings.CompositeObjectMapping, org.eclipse.persistence.internal.oxm.mappings.XMLConverterMapping
Known Direct Subclasses
org.eclipse.persistence.oxm.mappings.XMLVariableXPathCollectionMapping
Imports
java.lang.reflect.Modifier, java.util.Enumeration, .Vector, javax.xml.namespace.QName, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.DatabaseException, .DescriptorException, .XMLMarshalException, org.eclipse.persistence.internal.helper.DatabaseField, org.eclipse.persistence.internal.identitymaps.CacheKey, org.eclipse.persistence.internal.oxm.ConversionManager, .XMLObjectBuilder, .XPathEngine, .XPathFragment, .XPathQName, org.eclipse.persistence.internal.oxm.mappings.CompositeCollectionMapping, .Mapping, .XMLContainerMapping, org.eclipse.persistence.internal.queries.ContainerPolicy, .JoinedAttributeManager, .MapContainerPolicy, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, org.eclipse.persistence.mappings.AttributeAccessor, org.eclipse.persistence.mappings.converters.Converter, org.eclipse.persistence.mappings.foundation.AbstractCompositeCollectionMapping, org.eclipse.persistence.oxm.XMLConstants, .XMLContext, .XMLDescriptor, .XMLField, .XMLMarshaller, .XMLUnmarshaller, org.eclipse.persistence.oxm.mappings.converters.XMLConverter, org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy, .NullPolicy, .XMLNullRepresentationType, org.eclipse.persistence.oxm.record.DOMRecord, .XMLRecord, org.eclipse.persistence.platform.xml.XMLPlatformFactory, org.eclipse.persistence.queries.ObjectBuildingQuery, org.eclipse.persistence.sessions.Session, org.w3c.dom.Element, .Node, .NodeList

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 statements
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="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="customer" type="customer-type"/>
  <xsd:complexType name="customer-type">
    <xsd:sequence>
      <xsd:element name="first-name" type="xsd:string"/>
      <xsd:element name="last-name" type="xsd:string"/>
      <xsd:element name="phone-number">
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="number" type="xsd:string"/>
          </xsd:sequence>
          <xsd:attribute name="type" type="xsd:string"/>
        </xsd:complexType>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>
</xsd:schema>

Code Sample
XMLCompositeCollectionMapping phoneNumbersMapping = new XMLCompositeCollectionMapping();
phoneNumbersMapping.setAttributeName("phoneNumbers");
phoneNumbersMapping.setXPath("phone-number");
phoneNumbersMapping.setReferenceClass(PhoneNumber.class);

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.

Since
Oracle TopLink 10g Release 2 (10.1.3)

Field Summary

Modifier and TypeField and Description
private boolean
private XMLInverseReferenceMapping
private boolean
private UnmarshalKeepAsElementPolicy
pack-priv AbstractNullPolicy
private boolean
private AbstractNullPolicy
Inherited from org.eclipse.persistence.mappings.foundation.AbstractCompositeCollectionMapping:
converterfield

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Object
protected AbstractRecord
protected AbstractRecord
public Object
buildObjectFromNestedRow(AbstractRecord nestedRow, JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, AbstractSession executionSession, boolean isTargetProtected)

public void
public Object
public Object
private Object
convertToSimpleTypeIfPresent(Object objectToAdd, AbstractRecord nestedRow, AbstractSession executionSession)

public AttributeAccessor
getContainerAccessor()

Deprecated Replaced by getInverseReferenceMapping().getAttributeAccessor()
Gets the AttributeAccessor that is used to get and set the value of the container on the target object.
public String
getContainerAttributeName()

Deprecated Replaced by getInverseReferenceMapping().getAttributeName()
Gets the name of the backpointer attribute on the target object.
public String
getContainerGetMethodName()

Deprecated Replaced by getInverseReferenceMapping().getGetMethodName()
Gets the name of the method to be used when accessing the value of the back pointer on the target object of this mapping.
public String
getContainerSetMethodName()

Deprecated Replaced by getInverseReferenceMapping().getSetMethodName()
Gets the name of the method to be used when setting the value of the back pointer on the target object of this mapping.
protected XMLDescriptor
getDescriptor(XMLRecord xmlRecord, AbstractSession session, QName rootQName)

public XMLInverseReferenceMapping
public UnmarshalKeepAsElementPolicy
public AbstractNullPolicy
public ClassDescriptor
protected ClassDescriptor
public boolean
getReuseContainer()

Implements org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping.getReuseContainer.

Return true if the original container on the object should be used if present.
public AbstractNullPolicy
public String

Returns:

String the XPath String associated with this Mapping *
getXPath
()

Get the XPath String

public void
initialize(AbstractSession session)

Overrides org.eclipse.persistence.mappings.foundation.AbstractCompositeCollectionMapping.initialize.

INTERNAL: The mapping is initialized with the given session.
protected void
protected void
public boolean
isDefaultEmptyContainer()

Implements org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping.isDefaultEmptyContainer.

INTERNAL Return true if an empty container should be set on the object if there is no presence of the collection in the XML document.
public boolean
isWriteOnly()

Overrides org.eclipse.persistence.mappings.DatabaseMapping.isWriteOnly.

Implements org.eclipse.persistence.oxm.mappings.XMLMapping.isWriteOnly.

INTERNAL: Some mappings support no attribute (transformation and multitenant primary key).
public boolean
public void
preInitialize(AbstractSession session)

Overrides org.eclipse.persistence.mappings.DatabaseMapping.preInitialize.

INTERNAL: Allow for initialization of properties and validation.
public void
public void
setContainerAccessor(AttributeAccessor
- the accessor to be used.
anAttributeAccessor
)

Deprecated Replaced by getInverseReferenceMapping().setAttributeAccessor()
Sets the AttributeAccessor that is used to get and set the value of the container on the target object.
public void
setContainerAttributeName(String
- the name of the backpointer attribute to be populated
attributeName
)

Deprecated Replaced by getInverseReferenceMapping().setAttributeName()
Sets the name of the backpointer attribute on the target object.
public void
setContainerGetMethodName(String
- the name of the getter method to be used.
methodName
)

Deprecated Replaced by getInverseReferenceMapping().setGetMethodName()
Sets the method name to be used when accessing the value of the back pointer on the target object of this mapping.
public void
setContainerSetMethodName(String
- the name of the setter method to be used.
methodName
)

Deprecated Replaced by getInverseReferenceMapping().setSetMethodName()
Sets the name of the method to be used when setting the value of the back pointer on the target object of this mapping.
public void
setDefaultEmptyContainer(boolean defaultEmptyContainer)

Implements org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping.setDefaultEmptyContainer.

INTERNAL Indicate whether by default an empty container should be set on the field/property if the collection is not present in the XML document.
pack-priv void
public void
public void
public void
public void
setReuseContainer(boolean reuseContainer)

Implements org.eclipse.persistence.internal.oxm.mappings.XMLContainerMapping.setReuseContainer.

Specify whether the original container on the object should be used if present.
public void
public void
setXPath(String
String
xpathString
)

Implements org.eclipse.persistence.internal.oxm.mappings.CompositeObjectMapping.setXPath.

Set the Mapping field name attribute to the given XPath String
public Object
valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, CacheKey cacheKey, AbstractSession executionSession, boolean isTargetProtected, Boolean[] wasCacheUsed)

Overrides org.eclipse.persistence.mappings.foundation.AbstractCompositeCollectionMapping.valueFromRow.

INTERNAL: Build and return an aggregate collection from the specified row.
public void
public void
writeSingleValue(Object
- The value to be marshalled
value
,
Object parent, XMLRecord
- The Record the value is being marshalled too.
record
,
AbstractSession session)

Implements org.eclipse.persistence.internal.oxm.mappings.Mapping.writeSingleValue, org.eclipse.persistence.oxm.mappings.XMLMapping.writeSingleValue.

INTERNAL: A method that marshals a single value to the provided Record based on this mapping's XPath.
Inherited from org.eclipse.persistence.mappings.foundation.AbstractCompositeCollectionMapping:
buildAddedElementFromChangeSetbuildBackupClonePartbuildChangeSetbuildClonePartbuildCopyOfAttributeValuebuildElementFromChangeSetbuildElementFromElementbuildExpressionbuildRemovedElementFromChangeSetcascadeDiscoverAndPersistUnregisteredNewObjectscascadePerformRemoveIfRequiredcascadeRegisterNewIfRequiredcollectFieldscompareElementscompareElementsForChangecompareForChangecompareObjectsconvertToChangeRecordcreateMapComponentFromRowfixAttributeValuegetAttributeValueFromBackupClonegetContainerPolicygetConvertergetFieldgetRealCollectionAttributeValueFromObjectgetStructureNamehasConverterisAbstractCompositeCollectionMappingisCollectionMappingiterateOnAttributeValuemapKeyHasChangedmergeChangesIntoObjectmergeIntoObjectpostDeleteAttributeValuepostInsertAttributeValuepostUpdateAttributeValuepreDeleteAttributeValuepreInsertAttributeValuepreUpdateAttributeValuesetContainerPolicysetConvertersetFieldsimpleAddToCollectionChangeRecordsimpleRemoveFromCollectionChangeRecorduseCollectionClassuseCollectionClassNameuseListClassNameuseMapClassuseMapClassNameverifyDeleteOfAttributeValuewriteFromObjectIntoRowForUpdatewriteFromObjectIntoRowWithChangeRecordwriteInsertFieldsIntoRow