Module eclipselink

Class ObjectReferenceMapping

    • Field Detail

      • isForeignKeyRelationship

        protected boolean isForeignKeyRelationship
        Keeps track if any of the fields are foreign keys.
      • foreignKeyFields

        protected Vector<org.eclipse.persistence.internal.helper.DatabaseField> foreignKeyFields
        Keeps track of which fields are foreign keys on a per field basis (can have mixed foreign key relationships).
    • Constructor Detail

      • ObjectReferenceMapping

        protected ObjectReferenceMapping()
    • Method Detail

      • buildBackupCloneForPartObject

        public Object buildBackupCloneForPartObject​(Object attributeValue,
                                                    Object clone,
                                                    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. For 1-1 or ref the reference is from the clone so it is already registered.
        Specified by:
        buildBackupCloneForPartObject in class ForeignReferenceMapping
        Parameters:
        attributeValue - TODO
        clone - TODO
        backup - TODO
        unitOfWork - TODO
        Returns:
        TODO
      • buildCloneForPartObject

        public Object buildCloneForPartObject​(Object attributeValue,
                                              Object original,
                                              org.eclipse.persistence.internal.identitymaps.CacheKey cacheKey,
                                              Object clone,
                                              org.eclipse.persistence.internal.sessions.AbstractSession cloningSession,
                                              Integer refreshCascade,
                                              boolean isExisting,
                                              boolean isFromSharedCache)
        INTERNAL: Require for cloning, the part must be cloned. Ignore the objects, use the attribute value.
        Specified by:
        buildCloneForPartObject in class ForeignReferenceMapping
        Parameters:
        attributeValue - TODO
        original - TODO
        cacheKey - TODO
        clone - TODO
        cloningSession - TODO
        refreshCascade - TODO
        isExisting - TODO
        isFromSharedCache - TODO
        Returns:
        TODO
      • buildUnitofWorkCloneForPartObject

        public Object buildUnitofWorkCloneForPartObject​(Object attributeValue,
                                                        Object original,
                                                        Object clone,
                                                        Integer refreshCascade,
                                                        org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork,
                                                        boolean isExisting)
        INTERNAL: Require for cloning, the part must be cloned. Ignore the objects, use the attribute value.
      • buildCopy

        public void buildCopy​(Object copy,
                              Object original,
                              CopyGroup group)
        INTERNAL: Copy of the attribute of the object. This is NOT used for unit of work but for templatizing an object.
        Overrides:
        buildCopy in class DatabaseMapping
        Parameters:
        copy - TODO
        original - TODO
        group - TODO
      • 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 generates an expression from a attribute value pair. Since this is a ObjectReference mapping, a recursive call is made to the buildExpressionFromExample method of ObjectBuilder.
        Overrides:
        buildExpression in class DatabaseMapping
        Parameters:
        queryObject - TODO
        policy - TODO
        expressionBuilder - TODO
        processedObjects - TODO
        session - TODO
        Returns:
        TODO
      • 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: Return an ObjectReferenceChangeRecord describing the change, or null if no change. Used to compute changes for deferred change tracking.
        Specified by:
        compareForChange in class DatabaseMapping
        Parameters:
        clone - TODO
        backUp - TODO
        owner - TODO
        session - TODO
        Returns:
        prototype.changeset.ChangeRecord TODO
      • internalBuildChangeRecord

        public org.eclipse.persistence.internal.sessions.ObjectReferenceChangeRecord internalBuildChangeRecord​(Object newValue,
                                                                                                               org.eclipse.persistence.internal.sessions.ObjectChangeSet owner,
                                                                                                               org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Directly build a change record based on the newValue without comparison
      • setNewValueInChangeRecord

        public void setNewValueInChangeRecord​(Object newValue,
                                              org.eclipse.persistence.internal.sessions.ObjectReferenceChangeRecord changeRecord,
                                              org.eclipse.persistence.internal.sessions.ObjectChangeSet owner,
                                              org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Set the newValue in the change record
      • compareObjectsWithoutPrivateOwned

        protected boolean compareObjectsWithoutPrivateOwned​(Object firstObject,
                                                            Object secondObject,
                                                            org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Compare the references of the two objects are the same, not the objects themselves. Used for independent relationships. This is used for testing and validation purposes.
        Specified by:
        compareObjectsWithoutPrivateOwned in class ForeignReferenceMapping
      • compareObjectsWithPrivateOwned

        protected boolean compareObjectsWithPrivateOwned​(Object firstObject,
                                                         Object secondObject,
                                                         org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Compare the references of the two objects are the same, and the objects themselves are the same. Used for private relationships. This is used for testing and validation purposes.
        Specified by:
        compareObjectsWithPrivateOwned in class ForeignReferenceMapping
      • fixRealObjectReferences

        public void fixRealObjectReferences​(Object object,
                                            Map<Object,​org.eclipse.persistence.internal.sessions.remote.ObjectDescriptor> objectDescriptors,
                                            Map<Object,​Object> processedObjects,
                                            ObjectLevelReadQuery query,
                                            DistributedSession session)
        INTERNAL: We are not using a remote valueholder so we need to replace the reference object(s) with the corresponding object(s) from the remote session. ObjectReferenceMappings need to unwrap and wrap the reference object.
        Overrides:
        fixRealObjectReferences in class DatabaseMapping
        Parameters:
        object - TODO
        objectDescriptors - TODO
        processedObjects - TODO
        query - TODO
        session - TODO
      • getDescriptorForTarget

        public ClassDescriptor getDescriptorForTarget​(Object object,
                                                      org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Return a descriptor for the target of this mapping
        See Also:
        Bug 2612571
      • isObjectReferenceMapping

        public boolean isObjectReferenceMapping()
        INTERNAL: Related mapping should implement this method to return true.
        Overrides:
        isObjectReferenceMapping in class DatabaseMapping
      • iterateOnRealAttributeValue

        public void iterateOnRealAttributeValue​(org.eclipse.persistence.internal.descriptors.DescriptorIterator iterator,
                                                Object realAttributeValue)
        INTERNAL: Iterate on the attribute value. The value holder has already been processed.
        Specified by:
        iterateOnRealAttributeValue in class ForeignReferenceMapping
      • loadAll

        public void loadAll​(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 DatabaseMapping
      • 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. Which is the original from the parent UnitOfWork
        Specified by:
        mergeChangesIntoObject in class DatabaseMapping
      • 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.
        Specified by:
        mergeIntoObject in class DatabaseMapping
      • collectFields

        protected Vector<org.eclipse.persistence.internal.helper.DatabaseField> collectFields()
        INTERNAL: Return all the fields populated by this mapping, these are foreign keys only.
        Overrides:
        collectFields in class DatabaseMapping
        Returns:
        TODO
      • getForeignKeyFields

        public Vector<org.eclipse.persistence.internal.helper.DatabaseField> getForeignKeyFields()
        INTERNAL: Returns the foreign key names associated with the mapping. These are the fields that will be populated by the 1-1 mapping when writing.
      • setForeignKeyFields

        protected void setForeignKeyFields​(Vector<org.eclipse.persistence.internal.helper.DatabaseField> foreignKeyFields)
        INTERNAL: Set the foreign key fields associated with the mapping. These are the fields that will be populated by the 1-1 mapping when writing.
      • isForeignKeyRelationship

        public boolean isForeignKeyRelationship()
        INTERNAL: Return if the 1-1 mapping has a foreign key dependency to its target. This is true if any of the foreign key fields are true foreign keys, i.e. populated on write from the targets primary key.
      • setIsForeignKeyRelationship

        public void setIsForeignKeyRelationship​(boolean isForeignKeyRelationship)
        INTERNAL: Set if the 1-1 mapping has a foreign key dependency to its target. This is true if any of the foreign key fields are true foreign keys, i.e. populated on write from the targets primary key.
      • postCalculateChanges

        public void postCalculateChanges​(ChangeRecord changeRecord,
                                         org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)
        INTERNAL: Overridden by mappings that require additional processing of the change record after the record has been calculated.
        Overrides:
        postCalculateChanges in class DatabaseMapping
      • recordPrivateOwnedRemovals

        public void recordPrivateOwnedRemovals​(Object object,
                                               org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)
        INTERNAL: Overridden by mappings that require additional processing of the change record after the record has been calculated.
        Overrides:
        recordPrivateOwnedRemovals in class DatabaseMapping
      • earlyPreDelete

        public void earlyPreDelete​(DeleteObjectQuery query,
                                   Object object)
        INTERNAL: Record deletion dependencies for foreign key constraints. This is used during deletion to resolve deletion cycles.
        Overrides:
        earlyPreDelete in class DatabaseMapping
        Parameters:
        query - TODO
        object - TODO
      • cascadePerformRemoveIfRequired

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

        public void cascadePerformRemoveIfRequired​(Object object,
                                                   org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
                                                   Map visitedObjects,
                                                   boolean getAttributeValueFromObject)
        INTERNAL: Cascade remove through mappings that require the cascade.
        Parameters:
        object - is either the source object, or attribute value if getAttributeValueFromObject is true.
      • cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired

        public void cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired​(Object object,
                                                                                  org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
                                                                                  Map visitedObjects)
        INTERNAL: Cascade removal of orphaned private owned objects from the UnitOfWorkChangeSet
        Overrides:
        cascadePerformRemovePrivateOwnedObjectFromChangeSetIfRequired in class DatabaseMapping
        Parameters:
        object - TODO
        uow - TODO
        visitedObjects - TODO
      • collectQueryParameters

        public void collectQueryParameters​(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
        Specified by:
        collectQueryParameters in class ForeignReferenceMapping
        Parameters:
        cacheFields - TODO
      • 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
        Parameters:
        object - TODO
        newObjects - TODO
        unregisteredExistingObjects - TODO
        visitedObjects - TODO
        uow - TODO
        cascadeErrors - TODO
      • cascadeDiscoverAndPersistUnregisteredNewObjects

        public void cascadeDiscoverAndPersistUnregisteredNewObjects​(Object object,
                                                                    Map newObjects,
                                                                    Map unregisteredExistingObjects,
                                                                    Map visitedObjects,
                                                                    org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
                                                                    boolean getAttributeValueFromObject,
                                                                    Set cascadeErrors)
        INTERNAL: Cascade discover and persist new objects during commit.
      • 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
        Parameters:
        object - TODO
        uow - TODO
        visitedObjects - TODO
      • cascadeRegisterNewIfRequired

        public void cascadeRegisterNewIfRequired​(Object object,
                                                 org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow,
                                                 Map visitedObjects,
                                                 boolean getAttributeValueFromObject)
        INTERNAL: Cascade registerNew for Create through mappings that require the cascade
        Parameters:
        object - is either the source object, or attribute value if getAttributeValueFromObject is true.
      • getPrimaryKeyForObject

        protected Object getPrimaryKeyForObject​(Object object,
                                                org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL:
      • hasConstraintDependency

        public boolean hasConstraintDependency()
        INTERNAL: The returns if the mapping has any constraint dependencies, such as foreign keys and join tables.
        Overrides:
        hasConstraintDependency in class DatabaseMapping
      • createCloneValueHolder

        public <T> org.eclipse.persistence.internal.indirection.DatabaseValueHolder<T> createCloneValueHolder​(ValueHolderInterface<T> attributeValue,
                                                                                                              Object original,
                                                                                                              Object clone,
                                                                                                              org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                                                                                              org.eclipse.persistence.internal.sessions.AbstractSession cloningSession,
                                                                                                              boolean buildDirectlyFromRow)
        INTERNAL: Builder the unit of work value holder.
        Overrides:
        createCloneValueHolder in class ForeignReferenceMapping
        Parameters:
        buildDirectlyFromRow - indicates that we are building the clone directly from a row as opposed to building the original from the row, putting it in the shared cache, and then cloning the original.
        attributeValue - TODO
        original - TODO
        clone - TODO
        row - TODO
        cloningSession - TODO
        Returns:
        TODO
      • extractPrimaryKeyRowForSourceObject

        public org.eclipse.persistence.internal.sessions.AbstractRecord extractPrimaryKeyRowForSourceObject​(Object domainObject,
                                                                                                            org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Extract the reference pk for rvh usage in remote model.
      • extractPrimaryKeysForReferenceObject

        public Object extractPrimaryKeysForReferenceObject​(Object domainObject,
                                                           org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Extract the reference pk for rvh usage in remote model.
      • extractPrimaryKeysForReferenceObjectFromRow

        public Object extractPrimaryKeysForReferenceObjectFromRow​(org.eclipse.persistence.internal.sessions.AbstractRecord row)
        INTERNAL: Return the primary key for the reference object (i.e. the object object referenced by domainObject and specified by mapping). This key will be used by a RemoteValueHolder.
      • extractPrimaryKeysFromRealReferenceObject

        public Object extractPrimaryKeysFromRealReferenceObject​(Object object,
                                                                org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Extract the reference pk for rvh usage in remote model.
      • hasRelationTableMechanism

        public boolean hasRelationTableMechanism()
        PUBLIC: Indicates whether the mapping has RelationTableMechanism.
      • useProxyIndirection

        public void useProxyIndirection()
        PUBLIC: Set this mapping to use Proxy Indirection. Proxy Indirection uses the Proxy and InvocationHandler features of JDK 1.3 to provide "transparent indirection" for 1:1 relationships. In order to use Proxy Indirection:
        • The target class must implement at least one public interface
        • The attribute on the source class must be typed as that public interface
        • get() and set() methods for the attribute must use the interface
        With this policy, proxy objects are returned during object creation. When a message other than toString is called on the proxy the real object data is retrieved from the database. By default, use the target class' full list of interfaces for the proxy.
      • buildReferencesPKList

        public Object[] buildReferencesPKList​(Object entity,
                                              Object attribute,
                                              org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: This method will access the target relationship and create a list of PKs of the target entities. This method is used in combination with the CachedValueHolder to store references to PK's to be loaded from a cache instead of a query.
        Specified by:
        buildReferencesPKList in class ForeignReferenceMapping
        See Also:
        ContainerPolicy.buildReferencesPKList(java.lang.Object, org.eclipse.persistence.internal.sessions.AbstractSession), MappedKeyMapContainerPolicy
      • buildTargetInterfaces

        public Collection buildTargetInterfaces​(Class<?> aClass,
                                                Collection targetInterfacesCol)
        INTERNAL: Build a list of all the interfaces and super interfaces for a given class.
      • useProxyIndirection

        public void useProxyIndirection​(Class<?>[] targetInterfaces)
        PUBLIC: Set this mapping to use Proxy Indirection. Proxy Indirection uses the Proxy and InvocationHandler features of JDK 1.3 to provide "transparent indirection" for 1:1 relationships. In order to use Proxy Indirection:
        • The target class must implement at least one public interface
        • The attribute on the source class must be typed as that public interface
        • get() and set() methods for the attribute must use the interface
        With this policy, proxy objects are returned during object creation. When a message other than toString is called on the proxy the real object data is retrieved from the database.
        Parameters:
        targetInterfaces - The interfaces that the target class implements. The attribute must be typed as one of these interfaces.
      • useProxyIndirection

        public void useProxyIndirection​(Class<?> targetInterface)
        PUBLIC: Set this mapping to use Proxy Indirection. Proxy Indirection uses the Proxy and InvocationHandler features of JDK 1.3 to provide "transparent indirection" for 1:1 relationships. In order to use Proxy Indirection:
        • The target class must implement at least one public interface
        • The attribute on the source class must be typed as that public interface
        • get() and set() methods for the attribute must use the interface
        With this policy, proxy objects are returned during object creation. When a message other than toString is called on the proxy the real object data is retrieved from the database.
        Parameters:
        targetInterface - The interface that the target class implements. The attribute must be typed as this interface.
      • valueFromPKList

        public Object valueFromPKList​(Object[] pks,
                                      org.eclipse.persistence.internal.sessions.AbstractRecord foreignKeys,
                                      org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: This method is used to load a relationship from a list of PKs. This list may be available if the relationship has been cached.
        Specified by:
        valueFromPKList in class ForeignReferenceMapping
      • writeFromObjectIntoRowForUpdate

        public void writeFromObjectIntoRowForUpdate​(WriteObjectQuery query,
                                                    org.eclipse.persistence.internal.sessions.AbstractRecord databaseRow)
        INTERNAL: Get a value from the object and set that in the respective field of the row. But before that check if the reference object is instantiated or not.
        Overrides:
        writeFromObjectIntoRowForUpdate in class DatabaseMapping
      • updateChangeRecord

        public void updateChangeRecord​(Object clone,
                                       Object newValue,
                                       Object oldValue,
                                       org.eclipse.persistence.internal.sessions.ObjectChangeSet objectChangeSet,
                                       org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)
        INTERNAL: Either create a new change record or update the change record with the new value. This is used by attribute change tracking.
        Overrides:
        updateChangeRecord in class DatabaseMapping
      • updateChangeRecordForSelfMerge

        public void updateChangeRecordForSelfMerge​(org.eclipse.persistence.internal.sessions.ChangeRecord changeRecord,
                                                   Object source,
                                                   Object target,
                                                   org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet parentUOWChangeSet,
                                                   org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork)
        INTERNAL: Update a ChangeRecord to replace the ChangeSet for the old entity with the changeSet for the new Entity. This is used when an Entity is merged into itself and the Entity reference new or detached entities.
        Specified by:
        updateChangeRecordForSelfMerge in class ForeignReferenceMapping
      • buildChangeRecord

        public org.eclipse.persistence.internal.sessions.ChangeRecord buildChangeRecord​(Object clone,
                                                                                        org.eclipse.persistence.internal.sessions.ObjectChangeSet owner,
                                                                                        org.eclipse.persistence.internal.sessions.AbstractSession session)
        INTERNAL: Directly build a change record without comparison
        Overrides:
        buildChangeRecord in class DatabaseMapping