EclipseLink 2.0.0, build 'v20091117-r5801' API Reference

org.eclipse.persistence.oxm.mappings
Class XMLObjectReferenceMapping

java.lang.Object
  extended by org.eclipse.persistence.mappings.DatabaseMapping
      extended by org.eclipse.persistence.mappings.AggregateMapping
          extended by org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, XMLMapping
Direct Known Subclasses:
XMLCollectionReferenceMapping

public class XMLObjectReferenceMapping
extends AggregateMapping
implements XMLMapping

TopLink OXM version of a 1-1 mapping. A list of source-target key field associations is used to link the source xpaths to their related target xpaths, and hence their primary key (unique identifier) values used when (un)marshalling. This mapping has a Vector of XMLFields as opposed to a single XMLField. It is important to note that each target xpath is assumed to be set as a primary key field on the target (reference) class descriptor - this is necessary in order to locate the correct target object instance in the session cache when resolving mapping references.

See Also:
Serialized Form

Field Summary
protected  java.util.HashMap sourceToTargetKeyFieldAssociations
           
protected  java.util.Vector sourceToTargetKeys
           
 
Fields inherited from class org.eclipse.persistence.mappings.AggregateMapping
referenceClass, referenceClassName, referenceDescriptor
 
Fields inherited from class org.eclipse.persistence.mappings.DatabaseMapping
attributeAccessor, attributeName, derivedIdMapping, derivesId, descriptor, fields, isJPAId, isLazy, isMapKeyMapping, isOptional, isPrimaryKeyMapping, isReadOnly, isRemotelyInitialized, mapsIdValue, NO_FIELDS, NO_WEIGHT, properties, weight, WEIGHT_1
 
Constructor Summary
XMLObjectReferenceMapping()
          PUBLIC: The default constructor initializes the sourceToTargetKeyFieldAssociations and sourceToTargetKeys data structures.
 
Method Summary
 void addSourceToTargetKeyFieldAssociation(java.lang.String srcXPath, java.lang.String tgtXPath)
          PUBLIC: Add a source-target xpath pair to the map.
 java.lang.Object buildFieldValue(java.lang.Object targetObject, XMLField xmlFld, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Retrieve the target object's primary key value that is mapped to a given source xpath (in the source-target key field association list).
 void buildReference(UnmarshalRecord record, XMLField xmlField, java.lang.Object object, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Create (if necessary) and populate a reference object that will be used during the mapping reference resolution phase after unmarshalling is complete.
 void cascadePerformRemoveIfRequired(java.lang.Object object, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, java.util.Map visitedObjects)
          INTERNAL: Cascade perform delete through mappings that require the cascade
 void cascadeRegisterNewIfRequired(java.lang.Object object, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, java.util.Map visitedObjects)
          INTERNAL: Cascade registerNew for Create through mappings that require the cascade
 BidirectionalPolicy getBidirectionalPolicy()
           
 AttributeAccessor getBidirectionalTargetAccessor()
          Gets the AttributeAccessor that is used to get and set the value of the container on the target object.
 java.lang.String getBidirectionalTargetAttributeName()
          Gets the name of the backpointer attribute on the target object.
 org.eclipse.persistence.internal.queries.ContainerPolicy getBidirectionalTargetContainerPolicy()
           
 java.lang.String getBidirectionalTargetGetMethodName()
          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 getBidirectionalTargetSetMethodName()
          Gets the name of the method to be used when setting the value of the back pointer on the target object of this mapping.
 java.util.Vector getFields()
          INTERNAL: Return a list of XMLFields based on the source XPath values in the source-target key field associations list.
protected  javax.xml.namespace.QName getSchemaType(XMLField xmlField, java.lang.Object value, org.eclipse.persistence.internal.sessions.AbstractSession session)
          Return a QName representation the schema type for a given XMLField, if applicable.
protected  javax.xml.namespace.QName getSingleValueToWriteForUnion(XMLUnionField xmlField, java.lang.Object value, org.eclipse.persistence.internal.sessions.AbstractSession session)
          Return a single QName representation for a given XMLUnionField, if applicable.
 java.util.HashMap getSourceToTargetKeyFieldAssociations()
          INTERNAL: Return a list of source-target xmlfield pairs.
protected  java.lang.String getValueToWrite(javax.xml.namespace.QName schemaType, java.lang.Object value, org.eclipse.persistence.internal.sessions.AbstractSession session)
          Return a string representation of a given value, based on a given schema type.
 void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Register a ReferenceResolver as an event listener on the session, if one doesn't already exist.
 boolean isWriteOnly()
          INTERNAL: Some mappings support no attribute (transformation).
 boolean isXMLMapping()
          INTERNAL: Indicates that this is an XML mapping.
 void preInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Allow for initialization of properties and validation.
 java.lang.Object readFromRowIntoObject(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow, org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager, java.lang.Object targetObject, ObjectBuildingQuery sourceQuery, org.eclipse.persistence.internal.sessions.AbstractSession executionSession)
          INTERNAL: Extract the primary key values from the row, then create an org.eclipse.persistence.internal.oxm.Reference instance and store it on the session's org.eclipse.persistence.internal.oxm.ReferenceResolver.
 void setAttributeValueInObject(java.lang.Object object, java.lang.Object value)
          INTERNAL: Set the value of the attribute mapped by this mapping.
 void setBidirectionalTargetAccessor(AttributeAccessor anAttributeAccessor)
          Sets the AttributeAccessor that is used to get and set the value of the container on the target object.
 void setBidirectionalTargetAttributeName(java.lang.String attributeName)
          Sets the name of the backpointer attribute on the target object.
 void setBidirectionalTargetContainerClass(java.lang.Class cls)
           
 void setBidirectionalTargetContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy cp)
           
 void setBidirectionalTargetGetMethodName(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 setBidirectionalTargetSetMethodName(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 setBirdirectionalPolicy(BidirectionalPolicy policy)
           
 void setField(org.eclipse.persistence.internal.helper.DatabaseField field)
           
 void setIsWriteOnly(boolean b)
           
 void setSourceToTargetKeyFieldAssociations(java.util.HashMap sourceToTargetKeyFieldAssociations)
          INTERNAL: Set the list of source-target xmlfield pairs.
 void writeFromObjectIntoRow(java.lang.Object object, org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session)
          INTERNAL: Write the attribute value from the object to the row.
 void writeSingleValue(java.lang.Object value, java.lang.Object parent, XMLRecord row, 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.AggregateMapping
buildAggregateDeleteQuery, buildAggregateModifyQuery, buildAggregateWriteQuery, buildBackupClone, buildBackupClonePart, buildClone, buildCloneFromRow, buildClonePart, buildClonePart, buildCopy, buildCopyOfAttributeValue, buildExpression, buildNewMergeInstanceOf, compareAttributeValues, compareForChange, compareObjects, convertClassNamesToClasses, executeEvent, fixAttributeValue, fixObjectReferences, getAttributeValueFromBackupClone, getObjectBuilder, getObjectBuilderForClass, getQueryManager, getReferenceClass, getReferenceClassName, getReferenceDescriptor, getReferenceDescriptor, getReferenceDescriptor, isAggregateMapping, iterate, iterateOnAttributeValue, mergeAttributeValue, mergeChangesIntoObject, mergeIntoObject, postDelete, postDeleteAttributeValue, postInsert, postInsertAttributeValue, postUpdate, postUpdateAttributeValue, preDelete, preDeleteAttributeValue, preInsert, preInsertAttributeValue, preUpdate, preUpdateAttributeValue, remoteInitialization, setReferenceClass, setReferenceClassName, setReferenceDescriptor, updateChangeRecord, verifyDelete, verifyDeleteOfAttributeValue
 
Methods inherited from class org.eclipse.persistence.mappings.DatabaseMapping
buildBackupCloneForPartObject, buildChangeRecord, buildCloneForPartObject, buildObjectJoinExpression, buildObjectJoinExpression, buildShallowOriginalFromRow, calculateDeferredChanges, cascadeDiscoverAndPersistUnregisteredNewObjects, cascadeMerge, cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired, clone, cloneFields, collectFields, createUnitOfWorkValueHolder, derivesId, earlyPreDelete, extractNestedExpressions, fixRealObjectReferences, getAttributeAccessor, getAttributeClassification, getAttributeName, getAttributeValueFromObject, getContainerPolicy, getDerivedIdMapping, getDescriptor, getField, getFieldClassification, getGetMethodName, getMapsIdValue, getObjectCorrespondingTo, getProperties, getProperty, getRealAttributeValueFromAttribute, getRealAttributeValueFromObject, getRealCollectionAttributeValueFromObject, getRelationshipPartner, getSelectFields, getSelectTables, getSetMethodName, getValueFromRemoteValueHolder, getWeight, hasConstraintDependency, hasDependency, hasInverseConstraintDependency, hasMapsIdValue, hasRootExpressionThatShouldUseOuterJoin, instantiateAttribute, isAbstractCompositeCollectionMapping, isAbstractCompositeDirectCollectionMapping, isAbstractCompositeObjectMapping, isAbstractDirectMapping, isAggregateCollectionMapping, isAggregateObjectMapping, isCandidateForPrivateOwnedRemoval, isCascadedLockingSupported, isChangeTrackingSupported, isCloningRequired, isCollectionMapping, isDatabaseMapping, isDirectCollectionMapping, isDirectMapMapping, isDirectToFieldMapping, isDirectToXMLTypeMapping, isEISMapping, isForeignReferenceMapping, isJoiningSupported, isJPAId, isLazy, isLockableMapping, isManyToManyMapping, isMapKeyMapping, isNestedTableMapping, isObjectReferenceMapping, isOneToManyMapping, isOneToOneMapping, isOptional, isPrimaryKeyMapping, isPrivateOwned, isReadOnly, isReferenceMapping, isRelationalMapping, isRemotelyInitialized, isStructureMapping, isTransformationMapping, isUnidirectionalOneToManyMapping, isUsingMethodAccess, isVariableOneToOneMapping, iterateOnRealAttributeValue, performDataModificationEvent, postCalculateChanges, postCalculateChangesOnDeleted, postInitialize, prepareCascadeLockingPolicy, readFromResultSetIntoObject, readOnly, readWrite, recordPrivateOwnedRemovals, rehashFieldDependancies, remotelyInitialized, replaceValueHoldersIn, setAttributeAccessor, setAttributeName, setChangeListener, setDerivedIdMapping, setDerivesId, setDescriptor, setFields, setGetMethodName, setIsJPAId, setIsLazy, setIsMapKeyMapping, setIsOptional, setIsPrimaryKeyMapping, setIsReadOnly, setMapsIdValue, setProperties, setProperty, setRealAttributeValueInObject, setSetMethodName, setWeight, simpleAddToCollectionChangeRecord, simpleRemoveFromCollectionChangeRecord, toString, updateCollectionChangeRecord, validateAfterInitialization, validateBeforeInitialization, valueFromObject, valueFromResultSet, valueFromRow, valueFromRow, writeFromAttributeIntoRow, writeFromObjectIntoRowForShallowInsert, writeFromObjectIntoRowForShallowInsertWithChangeRecord, writeFromObjectIntoRowForUpdate, writeFromObjectIntoRowForWhereClause, writeFromObjectIntoRowWithChangeRecord, writeInsertFieldsIntoRow, writeUpdateFieldsIntoRow
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sourceToTargetKeyFieldAssociations

protected java.util.HashMap sourceToTargetKeyFieldAssociations

sourceToTargetKeys

protected java.util.Vector sourceToTargetKeys
Constructor Detail

XMLObjectReferenceMapping

public XMLObjectReferenceMapping()
PUBLIC: The default constructor initializes the sourceToTargetKeyFieldAssociations and sourceToTargetKeys data structures.

Method Detail

addSourceToTargetKeyFieldAssociation

public void addSourceToTargetKeyFieldAssociation(java.lang.String srcXPath,
                                                 java.lang.String tgtXPath)
PUBLIC: Add a source-target xpath pair to the map.

Parameters:
srcXPath -
tgtXPath -

buildFieldValue

public java.lang.Object buildFieldValue(java.lang.Object targetObject,
                                        XMLField xmlFld,
                                        org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Retrieve the target object's primary key value that is mapped to a given source xpath (in the source-target key field association list).

Parameters:
sourceObject -
xmlFld -
session -
Returns:
null if the target object is null, the reference class is null, or a primary key field name does not exist on the reference descriptor that matches the target field name - otherwise, return the associated primary key value

buildReference

public void buildReference(UnmarshalRecord record,
                           XMLField xmlField,
                           java.lang.Object object,
                           org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Create (if necessary) and populate a reference object that will be used during the mapping reference resolution phase after unmarshalling is complete.

Parameters:
record -
xmlField -
object -
session -

cascadePerformRemoveIfRequired

public void cascadePerformRemoveIfRequired(java.lang.Object object,
                                           org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
                                           java.util.Map visitedObjects)
INTERNAL: Cascade perform delete through mappings that require the cascade

Specified by:
cascadePerformRemoveIfRequired in class DatabaseMapping

cascadeRegisterNewIfRequired

public void cascadeRegisterNewIfRequired(java.lang.Object object,
                                         org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
                                         java.util.Map visitedObjects)
INTERNAL: Cascade registerNew for Create through mappings that require the cascade

Specified by:
cascadeRegisterNewIfRequired in class DatabaseMapping

getFields

public java.util.Vector getFields()
INTERNAL: Return a list of XMLFields based on the source XPath values in the source-target key field associations list.

Overrides:
getFields in class DatabaseMapping

getSchemaType

protected javax.xml.namespace.QName getSchemaType(XMLField xmlField,
                                                  java.lang.Object value,
                                                  org.eclipse.persistence.internal.sessions.AbstractSession session)
Return a QName representation the schema type for a given XMLField, if applicable. Note: This method performs the same functionality as 'getSchemaType' in org.eclipse.persistence.internal.oxm.XMLSimpleMappingNodeValue.

Parameters:
xmlField -
value -
Returns:

getSingleValueToWriteForUnion

protected javax.xml.namespace.QName getSingleValueToWriteForUnion(XMLUnionField xmlField,
                                                                  java.lang.Object value,
                                                                  org.eclipse.persistence.internal.sessions.AbstractSession session)
Return a single QName representation for a given XMLUnionField, if applicable. Note: This method performs the same functionality as 'getSingleValueToWriteForUnion' in org.eclipse.persistence.internal.oxm.XMLSimpleMappingNodeValue.

Parameters:
xmlField -
value -
Returns:

getSourceToTargetKeyFieldAssociations

public java.util.HashMap getSourceToTargetKeyFieldAssociations()
INTERNAL: Return a list of source-target xmlfield pairs.

Returns:

getValueToWrite

protected java.lang.String getValueToWrite(javax.xml.namespace.QName schemaType,
                                           java.lang.Object value,
                                           org.eclipse.persistence.internal.sessions.AbstractSession session)
Return a string representation of a given value, based on a given schema type. Note: This method performs the same functionality as 'getValueToWrite' in org.eclipse.persistence.internal.oxm.XMLSimpleMappingNodeValue.

Parameters:
schemaType -
value -
Returns:

initialize

public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
                throws DescriptorException
INTERNAL: Register a ReferenceResolver as an event listener on the session, if one doesn't already exist. Each source/target field will have a namespace resolver set as well.

Overrides:
initialize in class AggregateMapping
Throws:
DescriptorException
See Also:
ReferenceResolver, NamespaceResolver

preInitialize

public void preInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session)
                   throws DescriptorException
Description copied from class: DatabaseMapping
INTERNAL: Allow for initialization of properties and validation.

Overrides:
preInitialize in class DatabaseMapping
Throws:
DescriptorException

isXMLMapping

public boolean isXMLMapping()
INTERNAL: Indicates that this is an XML mapping.

Overrides:
isXMLMapping in class DatabaseMapping

readFromRowIntoObject

public java.lang.Object readFromRowIntoObject(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow,
                                              org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
                                              java.lang.Object targetObject,
                                              ObjectBuildingQuery sourceQuery,
                                              org.eclipse.persistence.internal.sessions.AbstractSession executionSession)
                                       throws DatabaseException
INTERNAL: Extract the primary key values from the row, then create an org.eclipse.persistence.internal.oxm.Reference instance and store it on the session's org.eclipse.persistence.internal.oxm.ReferenceResolver.

Overrides:
readFromRowIntoObject in class DatabaseMapping
Throws:
DatabaseException

setField

public void setField(org.eclipse.persistence.internal.helper.DatabaseField field)
Parameters:
field -

setSourceToTargetKeyFieldAssociations

public void setSourceToTargetKeyFieldAssociations(java.util.HashMap sourceToTargetKeyFieldAssociations)
INTERNAL: Set the list of source-target xmlfield pairs.


writeFromObjectIntoRow

public void writeFromObjectIntoRow(java.lang.Object object,
                                   org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                   org.eclipse.persistence.internal.sessions.AbstractSession session)
INTERNAL: Write the attribute value from the object to the row.

Overrides:
writeFromObjectIntoRow in class DatabaseMapping

writeSingleValue

public void writeSingleValue(java.lang.Object value,
                             java.lang.Object parent,
                             XMLRecord row,
                             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
row - - The Record the value is being marshalled too.

setIsWriteOnly

public void setIsWriteOnly(boolean b)
Specified by:
setIsWriteOnly in interface XMLMapping

isWriteOnly

public boolean isWriteOnly()
Description copied from class: DatabaseMapping
INTERNAL: Some mappings support no attribute (transformation).

Specified by:
isWriteOnly in interface XMLMapping
Overrides:
isWriteOnly in class DatabaseMapping

setAttributeValueInObject

public void setAttributeValueInObject(java.lang.Object object,
                                      java.lang.Object value)
                               throws DescriptorException
Description copied from class: DatabaseMapping
INTERNAL: Set the value of the attribute mapped by this mapping.

Overrides:
setAttributeValueInObject in class DatabaseMapping
Throws:
DescriptorException

getBidirectionalTargetAccessor

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


setBidirectionalTargetAccessor

public void setBidirectionalTargetAccessor(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.

setBidirectionalTargetAttributeName

public void setBidirectionalTargetAttributeName(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

getBidirectionalTargetAttributeName

public java.lang.String getBidirectionalTargetAttributeName()
Gets the name of the backpointer attribute on the target object. Used to populate the backpointer.


setBidirectionalTargetGetMethodName

public void setBidirectionalTargetGetMethodName(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 doesn't exist on the reference class of this mapping, a DescriptorException will be thrown during initialize.

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

setBidirectionalTargetSetMethodName

public void setBidirectionalTargetSetMethodName(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 doesn't exist on the reference class of this mapping, a DescriptorException will be thrown during initialize.

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

getBidirectionalTargetGetMethodName

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


getBidirectionalTargetSetMethodName

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


getBidirectionalTargetContainerPolicy

public org.eclipse.persistence.internal.queries.ContainerPolicy getBidirectionalTargetContainerPolicy()

setBidirectionalTargetContainerPolicy

public void setBidirectionalTargetContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy cp)

setBidirectionalTargetContainerClass

public void setBidirectionalTargetContainerClass(java.lang.Class cls)

getBidirectionalPolicy

public BidirectionalPolicy getBidirectionalPolicy()

setBirdirectionalPolicy

public void setBirdirectionalPolicy(BidirectionalPolicy policy)

EclipseLink 2.0.0, build 'v20091117-r5801' API Reference