Class XMLInverseReferenceMapping

java.lang.Object
org.eclipse.persistence.core.mappings.CoreMapping<AttributeAccessor,org.eclipse.persistence.internal.sessions.AbstractSession,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField>
org.eclipse.persistence.mappings.DatabaseMapping
org.eclipse.persistence.mappings.AggregateMapping
org.eclipse.persistence.oxm.mappings.XMLInverseReferenceMapping
All Implemented Interfaces:
Serializable, Cloneable, org.eclipse.persistence.internal.oxm.mappings.InverseReferenceMapping<org.eclipse.persistence.internal.sessions.AbstractSession,AttributeAccessor,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField,DatabaseMapping,org.eclipse.persistence.internal.oxm.record.XMLRecord>, org.eclipse.persistence.internal.oxm.mappings.Mapping<org.eclipse.persistence.internal.sessions.AbstractSession,AttributeAccessor,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.oxm.record.XMLRecord>, ContainerMapping

public class XMLInverseReferenceMapping extends AggregateMapping implements org.eclipse.persistence.internal.oxm.mappings.InverseReferenceMapping<org.eclipse.persistence.internal.sessions.AbstractSession,AttributeAccessor,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField,DatabaseMapping,org.eclipse.persistence.internal.oxm.record.XMLRecord>, ContainerMapping
This mapping is used to map a back-pointer. It represents the "opposite" of one of the following relationship mappings:

  • XMLCompositeObjectMapping
  • XMLCompositeCollectionMapping
  • XMLObjectReferenceMapping
  • XMLCollectionReferenceMapping
When configuring an XMLInverseReferenceMapping, the "mappedBy" field must be set to the field on the reference class that maps to this Descriptor. For example:

// EMPLOYEE has a collection of PHONEs (phoneNumbers)
// PHONE has a back-pointer to EMPLOYEE (owningEmployee)

// EMPLOYEE Descriptor
XMLCompositeCollectionMapping phone = new XMLCompositeCollectionMapping();
phone.setReferenceClassName("org.example.PhoneNumber");
phone.setAttributeName("phoneNumbers");
...

// PHONE Descriptor
XMLInverseReferenceMapping owningEmployee = new XMLInverseReferenceMapping();
owningEmployee.setReferenceClassName("org.example.Employee");
owningEmployee.setMappedBy("phoneNumbers");
owningEmployee.setAttributeName("owningEmployee");
...
See Also:
  • Constructor Details

    • XMLInverseReferenceMapping

      public XMLInverseReferenceMapping()
  • Method Details

    • isXMLMapping

      public boolean isXMLMapping()
      Description copied from class: DatabaseMapping
      INTERNAL: All relational mappings should implement this method to return true.
      Overrides:
      isXMLMapping in class DatabaseMapping
    • initialize

      public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
      Description copied from class: AggregateMapping
      INTERNAL: Initialize the reference descriptor.
      Overrides:
      initialize in class AggregateMapping
      Throws:
      DescriptorException
    • preInitialize

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

      public void postInitialize(org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
      Description copied from class: DatabaseMapping
      INTERNAL: Allow for initialization of properties and validation that have dependecies no the descriptor being initialized.
      Overrides:
      postInitialize in class DatabaseMapping
      Throws:
      DescriptorException
    • getMappedBy

      public String getMappedBy()
    • setMappedBy

      public void setMappedBy(String mappedBy)
      Specified by:
      setMappedBy in interface org.eclipse.persistence.internal.oxm.mappings.InverseReferenceMapping<org.eclipse.persistence.internal.sessions.AbstractSession,AttributeAccessor,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField,DatabaseMapping,org.eclipse.persistence.internal.oxm.record.XMLRecord>
    • buildBackupClone

      public void buildBackupClone(Object clone, Object backup, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork)
      Description copied from class: AggregateMapping
      INTERNAL: Clone the attribute from the clone and assign it to the backup.
      Overrides:
      buildBackupClone in class AggregateMapping
    • buildClone

      public void buildClone(Object original, org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey, Object clone, Integer refreshCascade, org.eclipse.persistence.internal.sessions.AbstractSession cloningSession)
      Description copied from class: AggregateMapping
      INTERNAL: Clone the attribute from the original and assign it to the clone.
      Overrides:
      buildClone in class AggregateMapping
    • buildCloneFromRow

      public void buildCloneFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow, org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager, Object clone, org.eclipse.persistence.internal.identitymaps.CacheKey sharedCacheKey, ObjectBuildingQuery sourceQuery, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, org.eclipse.persistence.internal.sessions.AbstractSession executionSession)
      Description copied from class: AggregateMapping
      INTERNAL: A combination of readFromRowIntoObject and buildClone.

      buildClone assumes the attribute value exists on the original and can simply be copied.

      readFromRowIntoObject assumes that one is building an original.

      Both of the above assumptions are false in this method, and actually attempts to do both at the same time.

      Extract value from the row and set the attribute to this value in the working copy clone. In order to bypass the shared cache when in transaction a UnitOfWork must be able to populate working copies directly from the row.

      Overrides:
      buildCloneFromRow in class AggregateMapping
    • cascadePerformRemoveIfRequired

      public void cascadePerformRemoveIfRequired(Object object, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, Map visitedObjects)
      Description copied from class: DatabaseMapping
      INTERNAL: Cascade registerNew for Create through mappings that require the cascade
      Specified by:
      cascadePerformRemoveIfRequired in class DatabaseMapping
    • cascadeRegisterNewIfRequired

      public void cascadeRegisterNewIfRequired(Object object, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, Map visitedObjects)
      Description copied from class: DatabaseMapping
      INTERNAL: Cascade registerNew for Create through mappings that require the cascade
      Specified by:
      cascadeRegisterNewIfRequired in class DatabaseMapping
    • compareForChange

      public org.eclipse.persistence.internal.sessions.ChangeRecord compareForChange(Object clone, Object backup, org.eclipse.persistence.internal.sessions.ObjectChangeSet owner, org.eclipse.persistence.internal.sessions.AbstractSession session)
      Description copied from class: AggregateMapping
      INTERNAL: Compare the changes between two aggregates. Return a change record holding the changes.
      Overrides:
      compareForChange in class AggregateMapping
      Returns:
      prototype.changeset.ChangeRecord
    • compareObjects

      public boolean compareObjects(Object firstObject, Object secondObject, org.eclipse.persistence.internal.sessions.AbstractSession session)
      Description copied from class: AggregateMapping
      INTERNAL: Compare the attributes belonging to this mapping for the objects.
      Overrides:
      compareObjects in class AggregateMapping
    • fixObjectReferences

      public void fixObjectReferences(Object object, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, DistributedSession session)
      Description copied from class: AggregateMapping
      INTERNAL: An object has been serialized from the server to the remote client. Replace the transient attributes of the remote value holders with client-side objects.
      Overrides:
      fixObjectReferences in class AggregateMapping
    • iterate

      public void iterate(org.eclipse.persistence.internal.descriptors.DescriptorIterator iterator)
      Description copied from class: AggregateMapping
      INTERNAL: Iterate on the appropriate attribute value.
      Overrides:
      iterate in class AggregateMapping
    • mergeChangesIntoObject

      public void mergeChangesIntoObject(Object target, org.eclipse.persistence.internal.sessions.ChangeRecord changeRecord, Object source, org.eclipse.persistence.internal.sessions.MergeManager mergeManager, org.eclipse.persistence.internal.sessions.AbstractSession targetSession)
      Description copied from class: AggregateMapping
      INTERNAL: Merge changes from the source to the target object. With aggregates the merge must cascade to the object changes for the aggregate object because aggregate objects have no identity outside of themselves. The actual aggregate object does not need to be replaced, because even if the clone references another aggregate it appears the same to TopLink
      Overrides:
      mergeChangesIntoObject in class AggregateMapping
    • mergeIntoObject

      public void mergeIntoObject(Object target, boolean isTargetUninitialized, Object source, org.eclipse.persistence.internal.sessions.MergeManager mergeManager, org.eclipse.persistence.internal.sessions.AbstractSession targetSession)
      Description copied from class: AggregateMapping
      INTERNAL: Merge changes from the source to the target object. This merge is only called when a changeSet for the target does not exist or the target is uninitialized
      Overrides:
      mergeIntoObject in class AggregateMapping
    • setContainerPolicy

      public void setContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy)
      Description copied from interface: ContainerMapping
      PUBLIC: Set the mapping's container policy.
      Specified by:
      setContainerPolicy in interface ContainerMapping
      Specified by:
      setContainerPolicy in interface org.eclipse.persistence.internal.oxm.mappings.InverseReferenceMapping<org.eclipse.persistence.internal.sessions.AbstractSession,AttributeAccessor,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField,DatabaseMapping,org.eclipse.persistence.internal.oxm.record.XMLRecord>
    • getContainerPolicy

      public org.eclipse.persistence.internal.queries.ContainerPolicy getContainerPolicy()
      Description copied from class: DatabaseMapping
      INTERNAL: Return the mapping's containerPolicy.
      Specified by:
      getContainerPolicy in interface ContainerMapping
      Specified by:
      getContainerPolicy in interface org.eclipse.persistence.internal.oxm.mappings.Mapping<org.eclipse.persistence.internal.sessions.AbstractSession,AttributeAccessor,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.oxm.record.XMLRecord>
      Overrides:
      getContainerPolicy in class DatabaseMapping
    • useCollectionClass

      public void useCollectionClass(Class concreteClass)
      Description copied from interface: ContainerMapping
      PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.

      The container class must implement (directly or indirectly) the java.util.Collection interface.

      Specified by:
      useCollectionClass in interface ContainerMapping
      Specified by:
      useCollectionClass in interface org.eclipse.persistence.internal.oxm.mappings.InverseReferenceMapping<org.eclipse.persistence.internal.sessions.AbstractSession,AttributeAccessor,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField,DatabaseMapping,org.eclipse.persistence.internal.oxm.record.XMLRecord>
    • useCollectionClassName

      public void useCollectionClassName(String concreteClass)
      Description copied from interface: ContainerMapping
      PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.

      The container class must implement (directly or indirectly) the java.util.Collection interface.

      Specified by:
      useCollectionClassName in interface ContainerMapping
    • useListClassName

      public void useListClassName(String concreteClass)
      Description copied from interface: ContainerMapping
      PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.

      The container class must implement (directly or indirectly) the java.util.List interface.

      Specified by:
      useListClassName in interface ContainerMapping
    • useMapClass

      public void useMapClass(Class concreteClass, String methodName)
      Description copied from interface: ContainerMapping
      PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects. The key used to index a value in the Map is the value returned by a call to the specified zero-argument method. The method must be implemented by the class (or a superclass) of any value to be inserted into the Map.

      The container class must implement (directly or indirectly) the java.util.Map interface.

      To facilitate resolving the method, the mapping's referenceClass must set before calling this method.

      Specified by:
      useMapClass in interface ContainerMapping
    • useMapClassName

      public void useMapClassName(String concreteClass, String methodName)
      Description copied from interface: ContainerMapping
      PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects. The key used to index a value in the Map is the value returned by a call to the specified zero-argument method. The method must be implemented by the class (or a superclass) of any value to be inserted into the Map.

      The container class must implement (directly or indirectly) the java.util.Map interface.

      To facilitate resolving the method, the mapping's referenceClass must set before calling this method.

      Specified by:
      useMapClassName in interface ContainerMapping
    • getInlineMapping

      public DatabaseMapping getInlineMapping()
      Specified by:
      getInlineMapping in interface org.eclipse.persistence.internal.oxm.mappings.InverseReferenceMapping<org.eclipse.persistence.internal.sessions.AbstractSession,AttributeAccessor,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField,DatabaseMapping,org.eclipse.persistence.internal.oxm.record.XMLRecord>
    • setInlineMapping

      public void setInlineMapping(DatabaseMapping inlineMapping)
      Specified by:
      setInlineMapping in interface org.eclipse.persistence.internal.oxm.mappings.InverseReferenceMapping<org.eclipse.persistence.internal.sessions.AbstractSession,AttributeAccessor,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField,DatabaseMapping,org.eclipse.persistence.internal.oxm.record.XMLRecord>
    • writeSingleValue

      public void writeSingleValue(Object value, Object object, org.eclipse.persistence.internal.oxm.record.XMLRecord record, org.eclipse.persistence.internal.sessions.AbstractSession session)
      Specified by:
      writeSingleValue in interface org.eclipse.persistence.internal.oxm.mappings.Mapping<org.eclipse.persistence.internal.sessions.AbstractSession,AttributeAccessor,org.eclipse.persistence.internal.queries.ContainerPolicy,ClassDescriptor,org.eclipse.persistence.internal.helper.DatabaseField,org.eclipse.persistence.internal.oxm.record.XMLRecord>