EclipseLink 1.1.4, build 'v20100812-r7860' API Reference

org.eclipse.persistence.oxm.mappings
Class XMLCompositeCollectionMapping

java.lang.Object
  extended by org.eclipse.persistence.mappings.DatabaseMapping
      extended by org.eclipse.persistence.mappings.AggregateMapping
          extended by org.eclipse.persistence.mappings.foundation.AbstractCompositeCollectionMapping
              extended by org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ContainerMapping, XMLMapping, XMLNillableMapping

public class XMLCompositeCollectionMapping
extends AbstractCompositeCollectionMapping
implements XMLMapping, XMLNillableMapping

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="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.

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

Field Summary
 
Fields inherited from class org.eclipse.persistence.mappings.foundation.AbstractCompositeCollectionMapping
converter, field
 
Fields inherited from class org.eclipse.persistence.mappings.AggregateMapping
referenceClass, referenceClassName, referenceDescriptor
 
Fields inherited from class org.eclipse.persistence.mappings.DatabaseMapping
attributeAccessor, attributeName, descriptor, fields, isLazy, isOptional, isPrimaryKeyMapping, isReadOnly, isRemotelyInitialized, NO_FIELDS, NO_WEIGHT, properties, weight, WEIGHT_1
 
Constructor Summary
XMLCompositeCollectionMapping()
           
 
Method Summary
protected  java.lang.Object buildCompositeObject(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractRecord nestedRow, ObjectBuildingQuery query, org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManger)
           
protected  org.eclipse.persistence.internal.sessions.AbstractRecord buildCompositeRow(java.lang.Object attributeValue, org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord parentRow)
           
 AttributeAccessor getContainerAccessor()
          Gets the AttributeAccessor that is used to get and set the value of the container on the target object.
 java.lang.String getContainerAttributeName()
          Gets the name of the backpointer attribute on the target object.
 java.lang.String getContainerGetMethodName()
          Gets the name of the method to be used when accessing the value of the back pointer on the target object of this mapping.
 java.lang.String getContainerSetMethodName()
          Gets the name of the method to be used when setting the value of the back pointer on the target object of this mapping.
 AbstractNullPolicy getNullPolicy()
          INTERNAL: Get the AbstractNullPolicy from the Mapping.
protected  ClassDescriptor getReferenceDescriptor(java.lang.Class theClass, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: For inheritance purposes.
 ClassDescriptor getReferenceDescriptor(DOMRecord xmlRecord)
           
 java.lang.String getXPath()
          Get the XPath String
 void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: The mapping is initialized with the given session.
 boolean isXMLMapping()
          INTERNAL:
 void setContainerAccessor(AttributeAccessor anAttributeAccessor)
          Sets the AttributeAccessor that is used to get and set the value of the container on the target object.
 void setContainerAttributeName(java.lang.String attributeName)
          Sets the name of the backpointer attribute on the target object.
 void setContainerGetMethodName(java.lang.String methodName)
          Sets the method name to be used when accessing the value of the back pointer on the target object of this mapping.
 void setContainerSetMethodName(java.lang.String methodName)
          Sets the name of the method to be used when setting the value of the back pointer on the target object of this mapping.
 void setNullPolicy(AbstractNullPolicy aNullPolicy)
          Set the AbstractNullPolicy on the mapping
The default policy is NullPolicy.
 void setXPath(java.lang.String xpathString)
          Set the Mapping field name attribute to the given XPath String
 boolean shouldAddXsiType(XMLRecord record, ClassDescriptor descriptor)
          INTERNAL:
 java.lang.Object valueFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, org.eclipse.persistence.internal.sessions.AbstractSession executionSession)
          INTERNAL: Build and return an aggregate collection from the specified row.
 void writeFromObjectIntoRow(java.lang.Object object, org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL:
 void writeSingleValue(java.lang.Object value, java.lang.Object parent, XMLRecord record, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: A method that marshals a single value to the provided Record based on this mapping's XPath.
 
Methods inherited from class org.eclipse.persistence.mappings.foundation.AbstractCompositeCollectionMapping
buildAddedElementFromChangeSet, buildBackupClonePart, buildChangeSet, buildClonePart, buildCopyOfAttributeValue, buildElementFromChangeSet, buildElementFromElement, buildRemovedElementFromChangeSet, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadePerformRemoveIfRequired, cascadeRegisterNewIfRequired, collectFields, compareElements, compareElementsForChange, compareForChange, compareObjects, convertClassNamesToClasses, convertToChangeRecord, fixAttributeValue, getAttributeValueFromBackupClone, getContainerPolicy, getConverter, getField, getRealCollectionAttributeValueFromObject, getStructureName, hasConverter, isAbstractCompositeCollectionMapping, iterateOnAttributeValue, mapKeyHasChanged, mergeChangesIntoObject, mergeIntoObject, postDeleteAttributeValue, postInsertAttributeValue, postUpdateAttributeValue, preDeleteAttributeValue, preInsertAttributeValue, preUpdateAttributeValue, setContainerPolicy, setConverter, setField, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, useCollectionClass, useCollectionClassName, useListClassName, useMapClass, useMapClassName, verifyDeleteOfAttributeValue, writeFromObjectIntoRowForUpdate, writeFromObjectIntoRowWithChangeRecord, writeInsertFieldsIntoRow
 
Methods inherited from class org.eclipse.persistence.mappings.AggregateMapping
buildAggregateDeleteQuery, buildAggregateModifyQuery, buildAggregateWriteQuery, buildBackupClone, buildClone, buildCloneFromRow, buildCopy, buildExpression, buildNewMergeInstanceOf, compareAttributeValues, executeEvent, fixObjectReferences, getObjectBuilder, getObjectBuilderForClass, getQueryManager, getReferenceClass, getReferenceClassName, getReferenceDescriptor, getReferenceDescriptor, isAggregateMapping, iterate, mergeAttributeValue, postDelete, postInsert, postUpdate, preDelete, preInsert, preUpdate, remoteInitialization, setReferenceClass, setReferenceClassName, setReferenceDescriptor, updateChangeRecord, verifyDelete
 
Methods inherited from class org.eclipse.persistence.mappings.DatabaseMapping
addToCollectionChangeRecord, buildBackupCloneForPartObject, buildChangeRecord, buildCloneForPartObject, buildObjectJoinExpression, buildObjectJoinExpression, buildShallowOriginalFromRow, calculateDeferredChanges, cascadeMerge, cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired, clone, cloneFields, createUnitOfWorkValueHolder, extractNestedExpressions, fixRealObjectReferences, getAttributeAccessor, getAttributeClassification, getAttributeName, getAttributeValueFromObject, getDescriptor, getFieldClassification, getFields, getGetMethodName, getObjectCorrespondingTo, getProperties, getProperty, getRealAttributeValueFromAttribute, getRealAttributeValueFromObject, getRelationshipPartner, getSelectFields, getSelectTables, getSetMethodName, getValueFromRemoteValueHolder, getWeight, hasConstraintDependency, hasDependency, hasInverseConstraintDependency, hasRootExpressionThatShouldUseOuterJoin, instantiateAttribute, isAbstractCompositeDirectCollectionMapping, isAbstractCompositeObjectMapping, isAbstractDirectMapping, isAggregateCollectionMapping, isAggregateObjectMapping, isCandidateForPrivateOwnedRemoval, isCascadedLockingSupported, isChangeTrackingSupported, isCloningRequired, isCollectionMapping, isDatabaseMapping, isDirectCollectionMapping, isDirectMapMapping, isDirectToFieldMapping, isDirectToXMLTypeMapping, isEISMapping, isForeignReferenceMapping, isJoiningSupported, isLazy, isManyToManyMapping, isNestedTableMapping, isObjectReferenceMapping, isOneToManyMapping, isOneToOneMapping, isOptional, isPrimaryKeyMapping, isPrivateOwned, isReadOnly, isReferenceMapping, isRelationalMapping, isRemotelyInitialized, isStructureMapping, isTransformationMapping, isUnidirectionalOneToManyMapping, isUsingMethodAccess, isVariableOneToOneMapping, isWriteOnly, iterateOnRealAttributeValue, performDataModificationEvent, postCalculateChanges, postCalculateChangesOnDeleted, postInitialize, preInitialize, prepareCascadeLockingPolicy, readFromResultSetIntoObject, readFromRowIntoObject, readOnly, readWrite, rehashFieldDependancies, remotelyInitialized, removeFromCollectionChangeRecord, replaceValueHoldersIn, setAttributeAccessor, setAttributeName, setAttributeValueInObject, setChangeListener, setDescriptor, setFields, setGetMethodName, setIsLazy, setIsOptional, setIsPrimaryKeyMapping, setIsReadOnly, setProperties, setProperty, setRealAttributeValueInObject, setSetMethodName, setWeight, toString, updateCollectionChangeRecord, validateAfterInitialization, validateBeforeInitialization, valueFromObject, valueFromResultSet, valueFromRow, writeFromAttributeIntoRow, writeFromObjectIntoRowForShallowInsert, writeFromObjectIntoRowForShallowInsertWithChangeRecord, writeFromObjectIntoRowForWhereClause, writeUpdateFieldsIntoRow
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XMLCompositeCollectionMapping

public XMLCompositeCollectionMapping()
Method Detail

getContainerAccessor

public AttributeAccessor getContainerAccessor()
Gets the AttributeAccessor that is used to get and set the value of the container on the target object.


setContainerAccessor

public void setContainerAccessor(AttributeAccessor anAttributeAccessor)
Sets the AttributeAccessor that is used to get and set the value of the container on the target object.

Parameters:
anAttributeAccessor - - the accessor to be used.

setContainerAttributeName

public void setContainerAttributeName(java.lang.String attributeName)
Sets the name of the backpointer attribute on the target object. Used to populate the backpointer. If the specified attribute doesn't exist on the reference class of this mapping, a DescriptorException will be thrown during initialize.

Parameters:
attributeName - - the name of the backpointer attribute to be populated

getContainerAttributeName

public java.lang.String getContainerAttributeName()
Gets the name of the backpointer attribute on the target object.


setContainerGetMethodName

public void setContainerGetMethodName(java.lang.String methodName)
Sets the method name to be used when accessing the value of the back pointer on the target object of this mapping. If the specified method isn't declared on the reference class of this mapping, a DescriptorException will be thrown during initialize.

Parameters:
methodName - - the name of the getter method to be used.

getContainerGetMethodName

public java.lang.String getContainerGetMethodName()
Gets the name of the method to be used when accessing the value of the back pointer on the target object of this mapping.


getContainerSetMethodName

public java.lang.String getContainerSetMethodName()
Gets the name of the method to be used when setting the value of the back pointer on the target object of this mapping.


setContainerSetMethodName

public void setContainerSetMethodName(java.lang.String methodName)
Sets the name of the method to be used when setting the value of the back pointer on the target object of this mapping. If the specified method isn't declared on the reference class of this mapping, a DescriptorException will be raised during initialize.

Parameters:
methodName - - the name of the setter method to be used.

isXMLMapping

public boolean isXMLMapping()
INTERNAL:

Overrides:
isXMLMapping in class DatabaseMapping

initialize

public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
                throws DescriptorException
INTERNAL: The mapping is initialized with the given session. This mapping is fully initialized after this.

Overrides:
initialize in class AbstractCompositeCollectionMapping
Throws:
DescriptorException

getXPath

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

Returns:
String the XPath String associated with this Mapping *

setXPath

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

Parameters:
xpathString - String

buildCompositeObject

protected java.lang.Object buildCompositeObject(ClassDescriptor descriptor,
                                                org.eclipse.persistence.internal.sessions.AbstractRecord nestedRow,
                                                ObjectBuildingQuery query,
                                                org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManger)
Specified by:
buildCompositeObject in class AbstractCompositeCollectionMapping

buildCompositeRow

protected org.eclipse.persistence.internal.sessions.AbstractRecord buildCompositeRow(java.lang.Object attributeValue,
                                                                                     org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                                                     org.eclipse.persistence.internal.sessions.AbstractRecord parentRow)
Specified by:
buildCompositeRow in class AbstractCompositeCollectionMapping

writeFromObjectIntoRow

public void writeFromObjectIntoRow(java.lang.Object object,
                                   org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                   org.eclipse.persistence.internal.sessions.AbstractSession session)
                            throws DescriptorException
INTERNAL:

Overrides:
writeFromObjectIntoRow in class AbstractCompositeCollectionMapping
Throws:
DescriptorException

valueFromRow

public java.lang.Object valueFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                     org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
                                     ObjectBuildingQuery sourceQuery,
                                     org.eclipse.persistence.internal.sessions.AbstractSession executionSession)
                              throws DatabaseException
Description copied from class: AbstractCompositeCollectionMapping
INTERNAL: Build and return an aggregate collection from the specified row.

Overrides:
valueFromRow in class AbstractCompositeCollectionMapping
Throws:
DatabaseException

getReferenceDescriptor

public ClassDescriptor getReferenceDescriptor(DOMRecord xmlRecord)

getReferenceDescriptor

protected ClassDescriptor getReferenceDescriptor(java.lang.Class theClass,
                                                 org.eclipse.persistence.internal.sessions.AbstractSession session)
Description copied from class: AggregateMapping
INTERNAL: For inheritance purposes.

Overrides:
getReferenceDescriptor in class AggregateMapping

shouldAddXsiType

public boolean shouldAddXsiType(XMLRecord record,
                                ClassDescriptor descriptor)
INTERNAL:


writeSingleValue

public void writeSingleValue(java.lang.Object value,
                             java.lang.Object parent,
                             XMLRecord record,
                             org.eclipse.persistence.internal.sessions.AbstractSession session)
Description copied from interface: XMLMapping
INTERNAL: A method that marshals a single value to the provided Record based on this mapping's XPath. Used for Sequenced marshalling.

Specified by:
writeSingleValue in interface XMLMapping
Parameters:
value - - The value to be marshalled
record - - The Record the value is being marshalled too.

setNullPolicy

public void setNullPolicy(AbstractNullPolicy aNullPolicy)
Set the AbstractNullPolicy on the mapping
The default policy is NullPolicy.

Specified by:
setNullPolicy in interface XMLNillableMapping
Parameters:
aNullPolicy -

getNullPolicy

public AbstractNullPolicy getNullPolicy()
INTERNAL: Get the AbstractNullPolicy from the Mapping.
The default policy is NullPolicy.

Specified by:
getNullPolicy in interface XMLNillableMapping
Returns:

EclipseLink 1.1.4, build 'v20100812-r7860' API Reference