Class AggregateCollectionMapping

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, ContainerMapping, EmbeddableMapping, MapComponentMapping, RelationalMapping

    public class AggregateCollectionMapping
    extends CollectionMapping
    implements RelationalMapping, MapComponentMapping, EmbeddableMapping

    Purpose: The aggregate collection mapping is used to represent the aggregate relationship between a single source object and a collection of target objects. The target objects cannot exist without the existence of the source object (privately owned) Unlike the normal aggregate mapping, there is a target table being mapped from the target objects. Unlike normal 1:m mapping, there is no 1:1 back reference mapping, as foreign key constraints have been resolved by the aggregation.

    See Also:
    Serialized Form
    Author:
    King (Yaoping) Wang
    Since:
    TOPLink/Java 3.0
    • Field Detail

      • targetForeignKeyFields

        protected java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeyFields
        This is a key in the target table which is a foreign key in the target table.
      • sourceKeyFields

        protected java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields
        This is a primary key in the source table that is used as foreign key in the target table
      • targetForeignKeyToSourceKeys

        protected java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,​org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeyToSourceKeys
        Foreign keys in the target table to the related keys in the source table
      • aggregateToSourceFields

        protected java.util.Map<java.lang.String,​org.eclipse.persistence.internal.helper.DatabaseField> aggregateToSourceFields
        Map the name of a field in the aggregate collection descriptor to a field in the actual table specified in the mapping.
      • nestedAggregateToSourceFields

        protected java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​org.eclipse.persistence.internal.helper.DatabaseField>> nestedAggregateToSourceFields
        Map the name of an attribute of the reference descriptor mapped with AggregateCollectionMapping to aggregateToSourceFieldNames that should be applied to this mapping.
      • converters

        protected java.util.Map<java.lang.String,​Converter> converters
        List of converters to apply at initialize time to their cloned aggregate mappings.
      • remoteReferenceDescriptor

        protected ClassDescriptor remoteReferenceDescriptor
        In RemoteSession case the mapping needs the reference descriptor serialized from the server, but referenceDescriptor attribute defined as transient in the superclass. To overcome that in non-remote case referenceDescriptor is assigned to remoteReferenceDescriptor; in remote - another way around.
      • defaultSourceTable

        protected org.eclipse.persistence.internal.helper.DatabaseTable defaultSourceTable
        Default source table that should be used with the default source fields of this mapping.
      • isEntireObjectPK

        protected boolean isEntireObjectPK
        Indicates whether the entire target object is primary key - in that case the object can't be updated in the db, but rather deleted and then re-inserted.
      • updateListOrderFieldQuery

        protected transient DataModifyQuery updateListOrderFieldQuery
        These queries used to update listOrderField
      • bulkUpdateListOrderFieldQuery

        protected transient DataModifyQuery bulkUpdateListOrderFieldQuery
      • pkUpdateListOrderFieldQuery

        protected transient DataModifyQuery pkUpdateListOrderFieldQuery
      • isListOrderFieldUpdatable

        protected boolean isListOrderFieldUpdatable
        indicates whether listOrderField value could be updated in the db. Used only if listOrderField!=null
      • hasNestedIdentityReference

        protected java.lang.Boolean hasNestedIdentityReference
        Indicates whether the mapping (or at least one of its nested mappings, at any nested depth) references an entity. To return true the mapping (or nested mapping) should be ForeignReferenceMapping with non-null and non-aggregate reference descriptor. Lazily initialized.
    • Constructor Detail

      • AggregateCollectionMapping

        public AggregateCollectionMapping()
        PUBLIC: Default constructor.
    • Method Detail

      • addOverrideManyToManyMapping

        public void addOverrideManyToManyMapping​(ManyToManyMapping mapping)
        INTERNAL: In JPA users may specify overrides to apply to a many to many mapping on a shared embeddable descriptor. These settings are applied at initialize time, after the reference descriptor is cloned. In an aggregate collection case, this is not supported and currently silently ignored and does nothing.
        Specified by:
        addOverrideManyToManyMapping in interface EmbeddableMapping
      • addOverrideUnidirectionalOneToManyMapping

        public void addOverrideUnidirectionalOneToManyMapping​(UnidirectionalOneToManyMapping mapping)
        INTERNAL: In JPA users may specify overrides to apply to a unidirectional one to many mapping on a shared embeddable descriptor. These settings are applied at initialize time, after the reference descriptor is cloned. In an aggregate collection case, this is not supported and currently silently ignored and does nothing.
        Specified by:
        addOverrideUnidirectionalOneToManyMapping in interface EmbeddableMapping
      • addConverter

        public void addConverter​(Converter converter,
                                 java.lang.String attributeName)
        Add a converter to be applied to a mapping of the aggregate descriptor.
        Specified by:
        addConverter in interface EmbeddableMapping
      • addFieldNameTranslation

        public void addFieldNameTranslation​(java.lang.String sourceFieldName,
                                            java.lang.String aggregateFieldName)
        PUBLIC: Maps a field name in the aggregate descriptor to a field name in the source table.
      • addFieldTranslation

        public void addFieldTranslation​(org.eclipse.persistence.internal.helper.DatabaseField sourceField,
                                        java.lang.String aggregateField)
        PUBLIC: Maps a field name in the aggregate descriptor to a field in the source table.
        Specified by:
        addFieldTranslation in interface EmbeddableMapping
      • addFieldTranslations

        public void addFieldTranslations​(java.util.Map<java.lang.String,​org.eclipse.persistence.internal.helper.DatabaseField> map)
        PUBLIC: Maps a field name in the aggregate descriptor to a field name in the source table.
      • addNestedFieldNameTranslation

        public void addNestedFieldNameTranslation​(java.lang.String attributeName,
                                                  java.lang.String sourceFieldName,
                                                  java.lang.String aggregateFieldName)
        PUBLIC: Map the name of an attribute of the reference descriptor mapped with AggregateCollectionMapping to aggregateToSourceFieldNames that should be applied to this mapping.
      • addNestedFieldTranslation

        public void addNestedFieldTranslation​(java.lang.String attributeName,
                                              org.eclipse.persistence.internal.helper.DatabaseField sourceField,
                                              java.lang.String aggregateFieldName)
        PUBLIC: Map the name of an attribute of the reference descriptor mapped with AggregateCollectionMapping to aggregateToSourceFieldNames that should be applied to this mapping.
        Specified by:
        addNestedFieldTranslation in interface EmbeddableMapping
      • addNestedFieldNameTranslations

        public void addNestedFieldNameTranslations​(java.lang.String attributeName,
                                                   java.util.Map<java.lang.String,​org.eclipse.persistence.internal.helper.DatabaseField> map)
        PUBLIC: Map the name of an attribute of the reference descriptor mapped with AggregateCollectionMapping to aggregateToSourceFields that should be applied to this mapping.
      • addTargetForeignKeyField

        public void addTargetForeignKeyField​(org.eclipse.persistence.internal.helper.DatabaseField targetForeignKey,
                                             org.eclipse.persistence.internal.helper.DatabaseField sourceKey)
        PUBLIC: Define the target foreign key relationship in the 1-M aggregate collection mapping. Both the target foreign key field and the source primary key field must be specified.
        Overrides:
        addTargetForeignKeyField in class ForeignReferenceMapping
      • addTargetForeignKeyFieldName

        public void addTargetForeignKeyFieldName​(java.lang.String targetForeignKey,
                                                 java.lang.String sourceKey)
        PUBLIC: Define the target foreign key relationship in the 1-M aggregate collection mapping. Both the target foreign key field name and the source primary key field name must be specified.
      • buildBackupCloneForPartObject

        public java.lang.Object buildBackupCloneForPartObject​(java.lang.Object attributeValue,
                                                              java.lang.Object clone,
                                                              java.lang.Object backup,
                                                              org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork)
        INTERNAL: Used during building the backup shallow copy to copy the vector without re-registering the target objects.
        Overrides:
        buildBackupCloneForPartObject in class CollectionMapping
      • buildCloneForPartObject

        public java.lang.Object buildCloneForPartObject​(java.lang.Object attributeValue,
                                                        java.lang.Object original,
                                                        org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey,
                                                        java.lang.Object clone,
                                                        org.eclipse.persistence.internal.sessions.AbstractSession cloningSession,
                                                        java.lang.Integer refreshCascade,
                                                        boolean isExisting,
                                                        boolean isFromSharedCache)
        INTERNAL: Require for cloning, the part must be cloned. Ignore the objects, use the attribute value. this is identical to the super class except that the element must be added to the new aggregates collection so that the referenced objects will be cloned correctly
        Overrides:
        buildCloneForPartObject in class CollectionMapping
      • buildElementBackupClone

        protected java.lang.Object buildElementBackupClone​(java.lang.Object element,
                                                           org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork)
        INTERNAL: Clone the aggregate collection, if necessary.
      • buildElementClone

        public java.lang.Object buildElementClone​(java.lang.Object element,
                                                  java.lang.Object parent,
                                                  org.eclipse.persistence.internal.identitymaps.CacheKey parentCacheKey,
                                                  java.lang.Integer refreshCascade,
                                                  org.eclipse.persistence.internal.sessions.AbstractSession cloningSession,
                                                  boolean isExisting,
                                                  boolean isFromSharedCache)
        INTERNAL: Clone the aggregate collection, if necessary.
        Overrides:
        buildElementClone in class CollectionMapping
      • buildExpression

        public Expression buildExpression​(java.lang.Object queryObject,
                                          QueryByExamplePolicy policy,
                                          Expression expressionBuilder,
                                          java.util.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 CollectionMapping
      • collectQueryParameters

        public void collectQueryParameters​(java.util.Set<org.eclipse.persistence.internal.helper.DatabaseField> cacheFields)
        INTERNAL: This method is used to store the FK fields that can be cached that correspond to noncacheable mappings the FK field values will be used to re-issue the query when cloning the shared cache entity
        Overrides:
        collectQueryParameters in class CollectionMapping
      • convertClassNamesToClasses

        public void convertClassNamesToClasses​(java.lang.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 CollectionMapping
        Parameters:
        classLoader - Where to search for classes.
      • cascadeDiscoverAndPersistUnregisteredNewObjects

        public void cascadeDiscoverAndPersistUnregisteredNewObjects​(java.lang.Object object,
                                                                    java.util.Map newObjects,
                                                                    java.util.Map unregisteredExistingObjects,
                                                                    java.util.Map visitedObjects,
                                                                    org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
                                                                    java.util.Set cascadeErrors)
        INTERNAL: Cascade discover and persist new objects during commit.
        Overrides:
        cascadeDiscoverAndPersistUnregisteredNewObjects in class CollectionMapping
      • 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
        Overrides:
        cascadeRegisterNewIfRequired in class CollectionMapping
      • cascadePerformRemoveIfRequired

        public void cascadePerformRemoveIfRequired​(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
        Overrides:
        cascadePerformRemoveIfRequired in class CollectionMapping
      • cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired

        public void cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired​(java.lang.Object object,
                                                                                  org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
                                                                                  java.util.Map visitedObjects)
        INTERNAL: Cascade perform removal of orphaned private owned objects from the UnitOfWorkChangeSet
        Overrides:
        cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired in class CollectionMapping
      • compareForChange

        public org.eclipse.persistence.internal.sessions.ChangeRecord compareForChange​(java.lang.Object clone,
                                                                                       java.lang.Object backUp,
                                                                                       org.eclipse.persistence.internal.sessions.ObjectChangeSet owner,
                                                                                       org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: This method is used to create a change record from comparing two aggregate collections
        Overrides:
        compareForChange in class CollectionMapping
        Returns:
        ChangeRecord
      • compareMapCollectionForChange

        protected boolean compareMapCollectionForChange​(java.util.Map cloneObjectCollection,
                                                        java.util.Map backUpCollection,
                                                        org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Determine if an AggregateCollection that is contained as a map has changed by comparing the values in the clone to the values in the backup.
      • objectChangedListOrderDuringUpdate

        protected int objectChangedListOrderDuringUpdate​(WriteObjectQuery query,
                                                         int iMin,
                                                         int iMax,
                                                         int iShift)
      • objectChangedListOrderDuringUpdate

        protected int objectChangedListOrderDuringUpdate​(WriteObjectQuery query,
                                                         java.lang.Object key,
                                                         int newOrderValue)
      • compareObjects

        public boolean compareObjects​(java.lang.Object firstObject,
                                      java.lang.Object secondObject,
                                      org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Compare the attributes belonging to this mapping for the objects.
        Overrides:
        compareObjects in class CollectionMapping
      • compareLists

        public boolean compareLists​(java.util.List firstList,
                                    java.util.List secondList,
                                    org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Compare the attributes belonging to this mapping for the objects.
      • convertToChangeRecord

        protected org.eclipse.persistence.internal.sessions.ChangeRecord convertToChangeRecord​(java.lang.Object cloneCollection,
                                                                                               java.lang.Object backupCollection,
                                                                                               org.eclipse.persistence.internal.sessions.ObjectChangeSet owner,
                                                                                               org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: This method is used to convert the contents of an aggregateCollection into a changeRecord
        Parameters:
        owner - org.eclipse.persistence.internal.sessions.ObjectChangeSet the ChangeSet that uses this record
        cloneCollection - Object the collection to convert
        session - org.eclipse.persistence.internal.sessions.AbstractSession
        Returns:
        org.eclipse.persistence.internal.sessions.AggregateCollectionChangeRecord the changerecord representing this AggregateCollectionMapping
      • copyElement

        protected java.lang.Object copyElement​(java.lang.Object original,
                                               CopyGroup group)
        INTERNAL: Copies member's value
        Overrides:
        copyElement in class CollectionMapping
      • createMapComponentFromRow

        public java.lang.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.
        Specified by:
        createMapComponentFromRow in interface MapComponentMapping
      • deleteAll

        protected void deleteAll​(DeleteObjectQuery query,
                                 org.eclipse.persistence.internal.sessions.AbstractSession session)
                          throws DatabaseException
        To delete all the entries matching the selection criteria from the table stored in the referenced descriptor
        Throws:
        DatabaseException
      • executeEvent

        protected void executeEvent​(int eventCode,
                                    ObjectLevelModifyQuery query)
        INTERNAL: Execute a descriptor event for the specified event code.
      • extractKeyFromTargetRow

        protected java.lang.Object extractKeyFromTargetRow​(org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                                           org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Extract the source primary key value from the target row. Used for batch reading, most following same order and fields as in the mapping.
        Overrides:
        extractKeyFromTargetRow in class CollectionMapping
      • extractBatchKeyFromRow

        protected java.lang.Object extractBatchKeyFromRow​(org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                                          org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Extract the primary key value from the source row. Used for batch reading, most following same order and fields as in the mapping.
        Overrides:
        extractBatchKeyFromRow in class ForeignReferenceMapping
      • getAggregateRow

        public org.eclipse.persistence.internal.sessions.AbstractRecord getAggregateRow​(ObjectLevelModifyQuery query,
                                                                                        java.lang.Object object)
        INTERNAL: return the aggregate Record with the primary keys from the source table and target table
      • getDeleteAllCriteria

        protected Expression getDeleteAllCriteria​(org.eclipse.persistence.internal.sessions.AbstractSession session)
        Delete all criteria is created with target foreign keys and source keys. This criteria is then used to delete target records from the table.
      • getReferenceDescriptor

        public ClassDescriptor getReferenceDescriptor()
        INTERNAL: Return the referenceDescriptor. This is a descriptor which is associated with the reference class. NOTE: If you are looking for the descriptor for a specific aggregate object, use #getReferenceDescriptor(Object). This will ensure you get the right descriptor if the object's descriptor is part of an inheritance tree.
        Overrides:
        getReferenceDescriptor in class ForeignReferenceMapping
      • getReferenceDescriptor

        public ClassDescriptor getReferenceDescriptor​(java.lang.Class theClass,
                                                      org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: for inheritance purpose
      • getSourceKeyFieldNames

        public java.util.Vector getSourceKeyFieldNames()
        PUBLIC: Return the source key field names associated with the mapping. These are in-order with the targetForeignKeyFieldNames.
      • getSourceKeyFields

        public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getSourceKeyFields()
        INTERNAL: Return the source key names associated with the mapping
      • getTargetForeignKeyFieldNames

        public java.util.Vector getTargetForeignKeyFieldNames()
        PUBLIC: Return the target foregin key field names associated with the mapping. These are in-order with the sourceKeyFieldNames.
      • getTargetForeignKeyFields

        public java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> getTargetForeignKeyFields()
        INTERNAL: Return the target foregin key fields associated with the mapping
      • getTargetForeignKeyToSourceKeys

        public java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,​org.eclipse.persistence.internal.helper.DatabaseField> getTargetForeignKeyToSourceKeys()
        INTERNAL:
      • initialize

        public void initialize​(org.eclipse.persistence.internal.sessions.AbstractSession session)
                        throws DescriptorException
        INTERNAL: For aggregate collection mapping the reference descriptor is cloned. The cloned descriptor is then assigned primary keys and table names before initialize. Once cloned descriptor is initialized it is assigned as reference descriptor in the aggregate mapping. This is very specific behavior for aggregate mappings. The original descriptor is used only for creating clones and after that mapping never uses it. Some initialization is done in postInitialize to ensure the target descriptor's references are initialized.
        Overrides:
        initialize in class CollectionMapping
        Throws:
        DescriptorException
      • initializeUpdateListOrderQuery

        protected void initializeUpdateListOrderQuery​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                      java.lang.String queryType)
      • prepareNestedJoins

        public ObjectLevelReadQuery prepareNestedJoins​(org.eclipse.persistence.internal.queries.JoinedAttributeManager joinManager,
                                                       ObjectBuildingQuery baseQuery,
                                                       org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Clone and prepare the JoinedAttributeManager nested JoinedAttributeManager. This is used for nested joining as the JoinedAttributeManager passed to the joined build object.
        Overrides:
        prepareNestedJoins in class ForeignReferenceMapping
      • translateTablesAndFields

        protected static void translateTablesAndFields​(ClassDescriptor descriptor,
                                                       java.util.HashMap<org.eclipse.persistence.internal.helper.DatabaseField,​org.eclipse.persistence.internal.helper.DatabaseField> fieldTranslation,
                                                       java.util.HashMap<org.eclipse.persistence.internal.helper.DatabaseTable,​org.eclipse.persistence.internal.helper.DatabaseTable> tableTranslation)
        INTERNAL: Called in case fieldTranslation != null Sets new primary keys, tables, appends fieldTranslation to fieldMap so that all fields in mappings, inheritance etc. translated to the new ones.
      • updateNestedAggregateMappings

        protected void updateNestedAggregateMappings​(ClassDescriptor descriptor,
                                                     org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Called in case nestedAggregateToSourceFieldNames != null Updates AggregateObjectMappings and AggregateCollectionMappings of the reference descriptor.
      • initializeChildInheritance

        public void initializeChildInheritance​(ClassDescriptor parentDescriptor,
                                               org.eclipse.persistence.internal.sessions.AbstractSession session,
                                               java.util.HashMap<org.eclipse.persistence.internal.helper.DatabaseField,​org.eclipse.persistence.internal.helper.DatabaseField> fieldTranslation,
                                               java.util.HashMap<org.eclipse.persistence.internal.helper.DatabaseTable,​org.eclipse.persistence.internal.helper.DatabaseTable> tableTranslation)
                                        throws DescriptorException
        INTERNAL: For aggregate mapping the reference descriptor is cloned. Also the involved inheritance descriptor, its children and parents all need to be cloned. The cloned descriptors are then assigned primary keys and table names before initialize. Once cloned descriptor is initialized it is assigned as reference descriptor in the aggregate mapping. This is very specific behavior for aggregate mappings. The original descriptor is used only for creating clones and after that mapping never uses it. Some initialization is done in postInitialize to ensure the target descriptor's references are initialized.
        Throws:
        DescriptorException
      • initializeDeleteAllQuery

        protected void initializeDeleteAllQuery​(org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Initialize delete all query. This query is used to delete the collection of objects from the target table.
      • initializeParentInheritance

        public void initializeParentInheritance​(ClassDescriptor parentDescriptor,
                                                ClassDescriptor childDescriptor,
                                                org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                java.util.HashMap<org.eclipse.persistence.internal.helper.DatabaseField,​org.eclipse.persistence.internal.helper.DatabaseField> fieldTranslation,
                                                java.util.HashMap<org.eclipse.persistence.internal.helper.DatabaseTable,​org.eclipse.persistence.internal.helper.DatabaseTable> tableTranslation)
                                         throws DescriptorException
        INTERNAL: For aggregate mapping the reference descriptor is cloned. Also the involved inheritance descriptor, its children and parents all need to be cloned. The cloned descriptors are then assigned primary keys and table names before initialize. Once cloned descriptor is initialized it is assigned as reference descriptor in the aggregate mapping. This is very specific behavior for aggregate mappings. The original descriptor is used only for creating clones and after that mapping never uses it. Some initialization is done in postInitialize to ensure the target descriptor's references are initialized.
        Throws:
        DescriptorException
      • initializeSelectionCriteria

        protected void initializeSelectionCriteria​(org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Selection criteria is created with target foreign keys and source keys. This criteria is then used to read records from the target table.
      • initializeTargetForeignKeyToSourceKeys

        protected void initializeTargetForeignKeyToSourceKeys​(org.eclipse.persistence.internal.sessions.AbstractSession session)
                                                       throws DescriptorException
        INTERNAL: The foreign keys and the primary key names are converted to DatabaseFields and stored.
        Throws:
        DescriptorException
      • initializeTargetForeignKeyToSourceKeysWithDefaults

        protected void initializeTargetForeignKeyToSourceKeysWithDefaults​(org.eclipse.persistence.internal.sessions.AbstractSession session)
                                                                   throws DescriptorException
        INTERNAL: The foreign keys and the primary key names are converted to DatabaseFields and stored. The source keys are not specified by the user so primary keys are extracted from the reference descriptor.
        Throws:
        DescriptorException
      • iterateOnElement

        public void iterateOnElement​(org.eclipse.persistence.internal.descriptors.DescriptorIterator iterator,
                                     java.lang.Object element)
        INTERNAL: Iterate on the specified element.
        Overrides:
        iterateOnElement in class CollectionMapping
      • isSourceKeySpecified

        protected boolean isSourceKeySpecified()
        Checks if source key is specified or not.
      • load

        public void load​(java.lang.Object object,
                         org.eclipse.persistence.internal.queries.AttributeItem item,
                         org.eclipse.persistence.internal.sessions.AbstractSession session,
                         boolean fromFetchGroup)
        Force instantiation of the load group.
        Overrides:
        load in class CollectionMapping
      • loadAll

        public void loadAll​(java.lang.Object object,
                            org.eclipse.persistence.internal.sessions.AbstractSession session,
                            org.eclipse.persistence.internal.helper.IdentityHashSet loaded)
        Force instantiation of all indirections.
        Overrides:
        loadAll in class CollectionMapping
      • mergeChangesIntoObject

        public void mergeChangesIntoObject​(java.lang.Object target,
                                           org.eclipse.persistence.internal.sessions.ChangeRecord changeRecord,
                                           java.lang.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. Because this is a collection mapping, values are added to or removed from the collection based on the changeset
        Overrides:
        mergeChangesIntoObject in class CollectionMapping
      • mergeIntoObject

        public void mergeIntoObject​(java.lang.Object target,
                                    boolean isTargetUnInitialized,
                                    java.lang.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:
        mergeIntoObject in class CollectionMapping
      • postInitialize

        public void postInitialize​(org.eclipse.persistence.internal.sessions.AbstractSession session)
                            throws DescriptorException
        INTERNAL: For aggregate collection mapping the reference descriptor is cloned. The cloned descriptor is then assigned primary keys and table names before initialize. Once the cloned descriptor is initialized it is assigned as reference descriptor in the aggregate mapping. This is a very specific behavior for aggregate mappings. The original descriptor is used only for creating clones and after that the aggregate mapping never uses it. Some initialization is done in postInitialize to ensure the target descriptor's references are initialized.
        Overrides:
        postInitialize in class CollectionMapping
        Throws:
        DescriptorException
      • getInsertObjectQuery

        protected InsertObjectQuery getInsertObjectQuery​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                         ClassDescriptor desc)
        INTERNAL: Returns a clone of InsertObjectQuery from the ClassDescriptor's DescriptorQueryManager or a new one
      • getAndPrepareModifyQueryForInsert

        public InsertObjectQuery getAndPrepareModifyQueryForInsert​(ObjectLevelModifyQuery originalQuery,
                                                                   java.lang.Object object)
        INTERNAL: setup the modifyQuery for post insert/update and pre delete
      • prepareModifyQueryForDelete

        public void prepareModifyQueryForDelete​(ObjectLevelModifyQuery originalQuery,
                                                ObjectLevelModifyQuery modifyQuery,
                                                java.lang.Object wrappedObject,
                                                java.util.Map extraData)
        INTERNAL: setup the modifyQuery for pre delete
      • prepareModifyQueryForUpdate

        public void prepareModifyQueryForUpdate​(ObjectLevelModifyQuery originalQuery,
                                                ObjectLevelModifyQuery modifyQuery,
                                                java.lang.Object object)
        INTERNAL: setup the modifyQuery for update,
      • setSourceKeyFieldNames

        public void setSourceKeyFieldNames​(java.util.Vector fieldNames)
        PUBLIC: Set the source key field names associated with the mapping. These must be in-order with the targetForeignKeyFieldNames.
      • setSourceKeyFields

        public void setSourceKeyFields​(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> sourceKeyFields)
        INTERNAL: set all the primary key names associated with this mapping
      • setTargetForeignKeyFieldNames

        public void setTargetForeignKeyFieldNames​(java.util.Vector fieldNames)
        PUBLIC: Set the target foregin key field names associated with the mapping. These must be in-order with the sourceKeyFieldNames.
      • setTargetForeignKeyFields

        public void setTargetForeignKeyFields​(java.util.Vector<org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeyFields)
        INTERNAL: set the target foregin key fields associated with the mapping
      • setTargetForeignKeyToSourceKeys

        protected void setTargetForeignKeyToSourceKeys​(java.util.Map<org.eclipse.persistence.internal.helper.DatabaseField,​org.eclipse.persistence.internal.helper.DatabaseField> targetForeignKeyToSourceKeys)
      • simpleAddToCollectionChangeRecord

        public void simpleAddToCollectionChangeRecord​(java.lang.Object referenceKey,
                                                      java.lang.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. PLEASE ENSURE that the changes have been made in the object model first.
        Overrides:
        simpleAddToCollectionChangeRecord in class CollectionMapping
      • simpleRemoveFromCollectionChangeRecord

        public void simpleRemoveFromCollectionChangeRecord​(java.lang.Object referenceKey,
                                                           java.lang.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. PLEASE ENSURE that the changes have been made in the object model first.
        Overrides:
        simpleRemoveFromCollectionChangeRecord in class CollectionMapping
      • isCandidateForPrivateOwnedRemoval

        public boolean isCandidateForPrivateOwnedRemoval()
        INTERNAL: AggregateCollection contents should not be considered for addition to the UnitOfWork private owned objects list for removal.
        Overrides:
        isCandidateForPrivateOwnedRemoval in class DatabaseMapping
      • isCascadedLockingSupported

        public boolean isCascadedLockingSupported()
        INTERNAL Return true if this mapping supports cascaded version optimistic locking.
        Overrides:
        isCascadedLockingSupported in class DatabaseMapping
      • remoteInitialization

        public void remoteInitialization​(DistributedSession session)
        INTERNAL: Once a descriptor is serialized to the remote session, all its mappings and reference descriptors are traversed. Usually the mappings are initialized and the serialized reference descriptors are replaced with local descriptors if they already exist in the remote session.
        Overrides:
        remoteInitialization in class ForeignReferenceMapping
      • isListOrderFieldUpdatable

        public boolean isListOrderFieldUpdatable()
        PUBLIC: indicates whether listOrderField value could be updated in the db. Used only if listOrderField!=null
      • setIsListOrderFieldUpdatable

        public void setIsListOrderFieldUpdatable​(boolean isUpdatable)
        PUBLIC: indicates whether listOrderField value could be updated in the db. Used only if listOrderField!=null Default value is true.
      • setDefaultSourceTable

        public void setDefaultSourceTable​(org.eclipse.persistence.internal.helper.DatabaseTable table)
        PUBLIC: Set a default source table to use with the source fields of this mapping.
      • hasNestedIdentityReference

        public boolean hasNestedIdentityReference()
        INTERNAL: Indicates whether the mapping (or at least one of its nested mappings, at any nested depth) references an entity. To return true the mapping (or nested mapping) should be ForeignReferenceMapping with non-null and non-aggregate reference descriptor.
        Overrides:
        hasNestedIdentityReference in class ForeignReferenceMapping