Class AbstractCompositeCollectionMapping

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.mappings.foundation.AbstractCompositeCollectionMapping
All Implemented Interfaces:
Serializable, Cloneable, ContainerMapping, ArrayCollectionMapping
Direct Known Subclasses:
EISCompositeCollectionMapping, ObjectArrayMapping, XMLCompositeCollectionMapping

public abstract class AbstractCompositeCollectionMapping extends AggregateMapping implements ContainerMapping, ArrayCollectionMapping
Define an embedded collection of objects. This is used in structured data-types, such as EIS, NoSQL and object-relational Array (varray, nested table) data-types. The target objects must be aggregate (embedded) and are stored with the parent object.
See Also:
  • Field Details

    • field

      protected org.eclipse.persistence.internal.helper.DatabaseField field
      The aggregate objects are stored in a single field.
    • converter

      protected Converter converter
      Allows user defined conversion between the object attribute value and the database value.
  • Constructor Details

    • AbstractCompositeCollectionMapping

      public AbstractCompositeCollectionMapping()
      Default constructor.
  • Method Details

    • buildAddedElementFromChangeSet

      public Object buildAddedElementFromChangeSet(Object changeSet, org.eclipse.persistence.internal.sessions.MergeManager mergeManager, org.eclipse.persistence.internal.sessions.AbstractSession targetSession)
      INTERNAL: Build and return a new element based on the change set.
      Specified by:
      buildAddedElementFromChangeSet in interface ArrayCollectionMapping
    • buildBackupClonePart

      protected Object buildBackupClonePart(Object attributeValue, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork)
      Build and return a backup clone of the attribute.
      Overrides:
      buildBackupClonePart in class AggregateMapping
    • buildChangeSet

      public Object buildChangeSet(Object element, org.eclipse.persistence.internal.sessions.ObjectChangeSet owner, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Build and return a change set for the specified element.
      Specified by:
      buildChangeSet in interface ArrayCollectionMapping
    • buildClonePart

      protected Object buildClonePart(Object original, Object clone, org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey, Object attributeValue, Integer refreshCascade, org.eclipse.persistence.internal.sessions.AbstractSession clonningSession)
      Build and return a clone of the attribute.
      Overrides:
      buildClonePart in class AggregateMapping
    • buildCopyOfAttributeValue

      protected Object buildCopyOfAttributeValue(Object attributeValue, CopyGroup group)
      Copy of the attribute of the object. This is NOT used for unit of work but for templatizing an object.
      Overrides:
      buildCopyOfAttributeValue in class AggregateMapping
    • buildElementFromChangeSet

      protected Object buildElementFromChangeSet(Object changeSet, org.eclipse.persistence.internal.sessions.MergeManager mergeManager, org.eclipse.persistence.internal.sessions.AbstractSession targetSession)
      Build and return a new element based on the change set.
    • buildElementFromElement

      public Object buildElementFromElement(Object element, org.eclipse.persistence.internal.sessions.MergeManager mergeManager, org.eclipse.persistence.internal.sessions.AbstractSession targetSession)
      INTERNAL: Build and return a new element based on the specified element.
      Specified by:
      buildElementFromElement in interface ArrayCollectionMapping
    • buildExpression

      public Expression buildExpression(Object queryObject, QueryByExamplePolicy policy, Expression expressionBuilder, Map processedObjects, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: In case Query By Example is used, this method builds and returns an expression that corresponds to a single attribute and it's value.
      Overrides:
      buildExpression in class AggregateMapping
    • buildRemovedElementFromChangeSet

      public Object buildRemovedElementFromChangeSet(Object changeSet, org.eclipse.persistence.internal.sessions.MergeManager mergeManager, org.eclipse.persistence.internal.sessions.AbstractSession targetSession)
      INTERNAL: Build and return a new element based on the change set.
      Specified by:
      buildRemovedElementFromChangeSet in interface ArrayCollectionMapping
    • cascadePerformRemoveIfRequired

      public void cascadePerformRemoveIfRequired(Object object, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, Map visitedObjects)
      INTERNAL: Cascade perform delete through mappings that require the cascade
      Specified by:
      cascadePerformRemoveIfRequired in class DatabaseMapping
    • cascadeDiscoverAndPersistUnregisteredNewObjects

      public void cascadeDiscoverAndPersistUnregisteredNewObjects(Object object, Map newObjects, Map unregisteredExistingObjects, Map visitedObjects, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, Set cascadeErrors)
      INTERNAL: Cascade discover and persist new objects during commit.
      Overrides:
      cascadeDiscoverAndPersistUnregisteredNewObjects in class DatabaseMapping
    • cascadeRegisterNewIfRequired

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

      protected Vector collectFields()
      Return the fields handled by the mapping.
      Overrides:
      collectFields in class DatabaseMapping
    • compareElements

      public boolean compareElements(Object element1, Object element2, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Compare the non-null elements and return true if they are alike.
      Specified by:
      compareElements in interface ArrayCollectionMapping
    • compareElementsForChange

      public boolean compareElementsForChange(Object element1, Object element2, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Compare the non-null elements and return true if they are alike.
      Specified by:
      compareElementsForChange in interface ArrayCollectionMapping
    • convertClassNamesToClasses

      public void convertClassNamesToClasses(ClassLoader classLoader)
      INTERNAL: Convert all the class-name-based settings in this mapping to actual class-based settings. This method is used when converting a project that has been built with class names to a project with classes.
      Overrides:
      convertClassNamesToClasses in class AggregateMapping
      Parameters:
      classLoader -
    • convertToChangeRecord

      protected org.eclipse.persistence.internal.sessions.ChangeRecord convertToChangeRecord(Object cloneCollection, org.eclipse.persistence.internal.sessions.ObjectChangeSet owner, org.eclipse.persistence.internal.sessions.AbstractSession session)
    • fixAttributeValue

      protected void fixAttributeValue(Object attributeValue, Map objectDescriptors, Map processedObjects, ObjectLevelReadQuery query, DistributedSession session)
      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:
      fixAttributeValue in class AggregateMapping
    • getAttributeValueFromBackupClone

      protected Object getAttributeValueFromBackupClone(Object backupClone)
      Return the appropriate attribute value. This method is a hack to allow the aggregate collection subclass to override.... The intent is to return the aggregate object in the backup clone that corresponds to the one in the working copy. Since we don't know which element in the backup clone collection corresponds any given element in the working copy collection (there is no "primary key"); we simply return null, which will cause a new, empty, instance to be built and used for comparison.
      Overrides:
      getAttributeValueFromBackupClone in class AggregateMapping
    • getContainerPolicy

      public org.eclipse.persistence.internal.queries.ContainerPolicy getContainerPolicy()
      INTERNAL: Return the mapping's containerPolicy.
      Specified by:
      getContainerPolicy in interface ContainerMapping
      Overrides:
      getContainerPolicy in class DatabaseMapping
    • getConverter

      public Converter getConverter()
      PUBLIC: Return the converter on the mapping. A converter can be used to convert between the object's value and database value of the attribute.
    • getField

      public org.eclipse.persistence.internal.helper.DatabaseField getField()
      INTERNAL: Return the field mapped by this mapping.
      Overrides:
      getField in class DatabaseMapping
    • getRealCollectionAttributeValueFromObject

      public Object getRealCollectionAttributeValueFromObject(Object object, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DescriptorException
      INTERNAL: Convenience method. Return the value of an attribute, unwrapping value holders if necessary. If the value is null, build a new container.
      Specified by:
      getRealCollectionAttributeValueFromObject in interface ArrayCollectionMapping
      Overrides:
      getRealCollectionAttributeValueFromObject in class DatabaseMapping
      Throws:
      DescriptorException
    • getStructureName

      protected String getStructureName()
      This is required for ObjectArrayMapping which defines a name for the collection type. Currently this type name is not required or used in general with the SDK.
    • hasConverter

      public boolean hasConverter()
      PUBLIC: Indicates if there is a converter on the mapping.
    • isAbstractCompositeCollectionMapping

      public boolean isAbstractCompositeCollectionMapping()
      INTERNAL:
      Overrides:
      isAbstractCompositeCollectionMapping 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 AggregateMapping
      Throws:
      DescriptorException
    • iterateOnAttributeValue

      protected void iterateOnAttributeValue(org.eclipse.persistence.internal.descriptors.DescriptorIterator descriptorIterator, Object attributeValue)
      Iterate on the specified attribute value.
      Overrides:
      iterateOnAttributeValue in class AggregateMapping
    • mapKeyHasChanged

      public boolean mapKeyHasChanged(Object element, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Return whether the element's user-defined Map key has changed since it was cloned from the original version. Aggregate elements cannot change their keys without detection.
      Specified by:
      mapKeyHasChanged in interface ArrayCollectionMapping
    • postDeleteAttributeValue

      public void postDeleteAttributeValue(DeleteObjectQuery query, Object attributeValue) throws DatabaseException, OptimisticLockException
      The message is passed to its reference class descriptor.
      Overrides:
      postDeleteAttributeValue in class AggregateMapping
      Throws:
      DatabaseException
      OptimisticLockException
    • postInsertAttributeValue

      public void postInsertAttributeValue(WriteObjectQuery query, Object attributeValue) throws DatabaseException, OptimisticLockException
      The message is passed to its reference class descriptor.
      Overrides:
      postInsertAttributeValue in class AggregateMapping
      Throws:
      DatabaseException
      OptimisticLockException
    • postUpdateAttributeValue

      public void postUpdateAttributeValue(WriteObjectQuery query, Object attributeValue) throws DatabaseException, OptimisticLockException
      The message is passed to its reference class descriptor.
      Overrides:
      postUpdateAttributeValue in class AggregateMapping
      Throws:
      DatabaseException
      OptimisticLockException
    • preDeleteAttributeValue

      public void preDeleteAttributeValue(DeleteObjectQuery query, Object attributeValue) throws DatabaseException, OptimisticLockException
      The message is passed to its reference class descriptor.
      Overrides:
      preDeleteAttributeValue in class AggregateMapping
      Throws:
      DatabaseException
      OptimisticLockException
    • preInsertAttributeValue

      public void preInsertAttributeValue(WriteObjectQuery query, Object attributeValue) throws DatabaseException, OptimisticLockException
      The message is passed to its reference class descriptor.
      Overrides:
      preInsertAttributeValue in class AggregateMapping
      Throws:
      DatabaseException
      OptimisticLockException
    • preUpdateAttributeValue

      public void preUpdateAttributeValue(WriteObjectQuery query, Object attributeValue) throws DatabaseException, OptimisticLockException
      The message is passed to its reference class descriptor.
      Overrides:
      preUpdateAttributeValue in class AggregateMapping
      Throws:
      DatabaseException
      OptimisticLockException
    • setContainerPolicy

      public void setContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy containerPolicy)
      ADVANCED: Set the mapping's containerPolicy.
      Specified by:
      setContainerPolicy in interface ContainerMapping
    • setConverter

      public void setConverter(Converter converter)
      PUBLIC: Set the converter on the mapping. A converter can be used to convert between the object's value and database value of the attribute.
    • setField

      public void setField(org.eclipse.persistence.internal.helper.DatabaseField field)
      Set the field in the mapping.
    • useCollectionClass

      public void useCollectionClass(Class concreteContainerClass)
      PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects.

      jdk1.2.x: The container class must implement (directly or indirectly) the Collection interface.

      jdk1.1.x: The container class must be a subclass of Vector.

      Specified by:
      useCollectionClass in interface ContainerMapping
    • useCollectionClassName

      public void useCollectionClassName(String concreteContainerClassName)
      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 concreteContainerClassName)
      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 concreteContainerClass, String methodName)
      PUBLIC: Configure the mapping to use an instance of the specified container class to hold the target objects. The key used to index the 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 the value to be inserted into the Map.

      jdk1.2.x: The container class must implement (directly or indirectly) the Map interface.

      jdk1.1.x: The container class must be a subclass of Hashtable.

      The referenceClass must be set before calling this method.

      Specified by:
      useMapClass in interface ContainerMapping
    • useMapClassName

      public void useMapClassName(String concreteContainerClassName, 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
    • valueFromRow

      public Object valueFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager, ObjectBuildingQuery sourceQuery, org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey, org.eclipse.persistence.internal.sessions.AbstractSession executionSession, boolean isTargetProtected, Boolean[] wasCacheUsed) throws DatabaseException
      INTERNAL: Build and return an aggregate collection from the specified row.
      Overrides:
      valueFromRow in class DatabaseMapping
      Throws:
      DatabaseException
    • buildCompositeObject

      protected abstract Object buildCompositeObject(ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.AbstractRecord nestedRow, ObjectBuildingQuery query, org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey, org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManger, org.eclipse.persistence.internal.sessions.AbstractSession targetSession)
    • verifyDeleteOfAttributeValue

      protected boolean verifyDeleteOfAttributeValue(Object attributeValue, org.eclipse.persistence.internal.sessions.AbstractSession session) throws DatabaseException
      Return whether the specified object and all its components have been deleted.
      Overrides:
      verifyDeleteOfAttributeValue in class AggregateMapping
      Throws:
      DatabaseException
    • writeFromObjectIntoRow

      public void writeFromObjectIntoRow(Object object, org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session, DatabaseMapping.WriteType writeType) throws DescriptorException
      INTERNAL: Get the attribute value from the object and add the appropriate values to the specified database row.
      Overrides:
      writeFromObjectIntoRow in class DatabaseMapping
      Throws:
      DescriptorException
    • buildCompositeRow

      protected abstract org.eclipse.persistence.internal.sessions.AbstractRecord buildCompositeRow(Object attributeValue, org.eclipse.persistence.internal.sessions.AbstractSession session, org.eclipse.persistence.internal.sessions.AbstractRecord record, DatabaseMapping.WriteType writeType)
    • writeFromObjectIntoRowForUpdate

      public void writeFromObjectIntoRowForUpdate(WriteObjectQuery writeQuery, org.eclipse.persistence.internal.sessions.AbstractRecord row) throws DescriptorException
      INTERNAL: Get the attribute value from the object and add the changed values to the specified database row.
      Overrides:
      writeFromObjectIntoRowForUpdate in class DatabaseMapping
      Throws:
      DescriptorException
    • writeFromObjectIntoRowWithChangeRecord

      public void writeFromObjectIntoRowWithChangeRecord(org.eclipse.persistence.internal.sessions.ChangeRecord changeRecord, org.eclipse.persistence.internal.sessions.AbstractRecord row, org.eclipse.persistence.internal.sessions.AbstractSession session, DatabaseMapping.WriteType writeType) throws DescriptorException
      INTERNAL: Get the attribute value from the object and add the appropriate values to the specified database row.
      Overrides:
      writeFromObjectIntoRowWithChangeRecord in class DatabaseMapping
      Throws:
      DescriptorException
    • writeInsertFieldsIntoRow

      public void writeInsertFieldsIntoRow(org.eclipse.persistence.internal.sessions.AbstractRecord record, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Write fields needed for insert into the template with null values.
      Overrides:
      writeInsertFieldsIntoRow in class DatabaseMapping
    • isCollectionMapping

      public boolean isCollectionMapping()
      Description copied from class: DatabaseMapping
      INTERNAL: Related mapping should implement this method to return true.
      Overrides:
      isCollectionMapping 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)
      INTERNAL: Build and return the change record that results from comparing the two direct collection attributes.
      Overrides:
      compareForChange in class AggregateMapping
      Returns:
      prototype.changeset.ChangeRecord
    • compareObjects

      public boolean compareObjects(Object object1, Object object2, org.eclipse.persistence.internal.sessions.AbstractSession session)
      INTERNAL: Compare the attributes belonging to this mapping for the objects.
      Overrides:
      compareObjects 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)
      INTERNAL: Merge changes from the source to the target object.
      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)
      INTERNAL: Merge changes from the source to the target object. Simply replace the entire target collection.
      Overrides:
      mergeIntoObject in class AggregateMapping
    • simpleAddToCollectionChangeRecord

      public void simpleAddToCollectionChangeRecord(Object referenceKey, Object changeSetToAdd, org.eclipse.persistence.internal.sessions.ObjectChangeSet changeSet, org.eclipse.persistence.internal.sessions.AbstractSession session)
      ADVANCED: This method is used to have an object add to a collection once the changeSet is applied The referenceKey parameter should only be used for direct Maps.
      Overrides:
      simpleAddToCollectionChangeRecord in class DatabaseMapping
    • simpleRemoveFromCollectionChangeRecord

      public void simpleRemoveFromCollectionChangeRecord(Object referenceKey, Object changeSetToRemove, org.eclipse.persistence.internal.sessions.ObjectChangeSet changeSet, org.eclipse.persistence.internal.sessions.AbstractSession session)
      ADVANCED: This method is used to have an object removed from a collection once the changeSet is applied The referenceKey parameter should only be used for direct Maps.
      Overrides:
      simpleRemoveFromCollectionChangeRecord in class DatabaseMapping
    • createMapComponentFromRow

      public Object createMapComponentFromRow(org.eclipse.persistence.internal.sessions.AbstractRecord dbRow, ObjectBuildingQuery query, org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey, org.eclipse.persistence.internal.sessions.AbstractSession session, boolean isTargetProtected)
      INTERNAL Called when a DatabaseMapping is used to map the key in a collection. Returns the key.