Class DeferredChangeDetectionPolicy

java.lang.Object
org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy
All Implemented Interfaces:
Serializable, ObjectChangePolicy
Direct Known Subclasses:
ObjectChangeTrackingPolicy

public class DeferredChangeDetectionPolicy extends Object implements ObjectChangePolicy, Serializable
PUBLIC: A DeferredChangeDetectionPolicy defers all change detection to the UnitOfWork's change detection process. Essentially, the calculateChanges() method will run for all objects in a UnitOfWork. This is the default ObjectChangePolicy unless weaving is used.
See Also:
Author:
Tom Ware
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    buildBackupClone(Object clone, org.eclipse.persistence.internal.descriptors.ObjectBuilder builder, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)
    INTERNAL: Build back up clone.
    org.eclipse.persistence.internal.sessions.ObjectChangeSet
    calculateChanges(Object clone, Object backUp, boolean isNew, org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet changeSet, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor, boolean shouldRaiseEvent)
    INTERNAL: calculateChanges creates a change set for a particular object.
    org.eclipse.persistence.internal.sessions.ObjectChangeSet
    calculateChangesForExistingObject(Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet changeSet, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor, boolean shouldRaiseEvent)
    INTERNAL: PERF: Calculate change for the new object, avoids check for new since already know.
    org.eclipse.persistence.internal.sessions.ObjectChangeSet
    calculateChangesForNewObject(Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet changeSet, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor, boolean shouldRaiseEvent)
    INTERNAL: PERF: Calculate change for the new object, avoids check for new since already know.
    void
    clearChanges(Object object, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, ClassDescriptor descriptor, boolean forRefresh)
    INTERNAL: This is a place holder for reseting the listener on one of the subclasses
    org.eclipse.persistence.internal.sessions.ObjectChangeSet
    createObjectChangeSet(Object clone, Object backUp, org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet changeSet, boolean isNew, org.eclipse.persistence.internal.sessions.AbstractSession session, ClassDescriptor descriptor)
    INTERNAL: Create ObjectChangeSet
    org.eclipse.persistence.internal.sessions.ObjectChangeSet
    createObjectChangeSetThroughComparison(Object clone, Object backUp, org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet changeSet, boolean isNew, org.eclipse.persistence.internal.sessions.AbstractSession session, ClassDescriptor descriptor)
    INTERNAL: Create ObjectChangeSet
    void
    INTERNAL: This method is used to disable changetracking temporarily
    void
    INTERNAL: This method is used to enable changetracking temporarily
    void
    initialize(org.eclipse.persistence.internal.sessions.AbstractSession session, ClassDescriptor descriptor)
    INTERNAL: initialize the Policy
    boolean
    Used to track instances of the change policies without doing an instance of check
    boolean
    Used to track instances of the change policies without doing an instance of check
    boolean
    Used to track instances of the change policies without doing an instance of check
    void
    raiseInternalPropertyChangeEvent(Object source, String propertyName, Object oldValue, Object newValue)
    INTERNAL: This may cause a property change event to be raised to a listener in the case that a listener exists.
    void
    revertChanges(Object clone, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, Map cloneMapping, boolean forRefresh)
    INTERNAL: This method is used to revert an object within the unit of work
    void
    setAggregateChangeListener(Object parent, Object aggregate, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, ClassDescriptor descriptor, String mappingAttribute)
    INTERNAL: Assign ChangeListener to an aggregate object
    setChangeListener(Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, ClassDescriptor descriptor)
    INTERNAL: Set ChangeListener for the clone
    void
    setChangeSetOnListener(org.eclipse.persistence.internal.sessions.ObjectChangeSet objectChangeSet, Object clone)
    INTERNAL: Set the ObjectChangeSet on the Listener, initially used for aggregate support
    boolean
    shouldCompareExistingObjectForChange(Object object, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor)
    INTERNAL: Return true if the Object should be compared, false otherwise.
    void
    updateListenerForSelfMerge(org.eclipse.persistence.internal.descriptors.changetracking.ObjectChangeListener listener, ForeignReferenceMapping mapping, Object source, Object target, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork)
    INTERNAL: In cases where a relationship with detached or new entities is merged into itself previous changes may have been recorded for the detached/new entity that need to be updated.
    void
    updateWithChanges(Object clone, org.eclipse.persistence.internal.sessions.ObjectChangeSet objectChangeSet, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, ClassDescriptor descriptor)
    INTERNAL: Clear changes in the ChangeListener of the clone

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DeferredChangeDetectionPolicy

      public DeferredChangeDetectionPolicy()
  • Method Details

    • calculateChangesForNewObject

      public org.eclipse.persistence.internal.sessions.ObjectChangeSet calculateChangesForNewObject(Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet changeSet, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor, boolean shouldRaiseEvent)
      INTERNAL: PERF: Calculate change for the new object, avoids check for new since already know.
      Specified by:
      calculateChangesForNewObject in interface ObjectChangePolicy
      Parameters:
      clone - the Object to compute a change set for
      changeSet - the change set to add changes to
      unitOfWork - the current session
      descriptor - the descriptor for this object
      shouldRaiseEvent - indicates whether PreUpdate event should be risen (usually true)
      Returns:
      ObjectChangeSet an object change set describing the changes to this object
    • calculateChangesForExistingObject

      public org.eclipse.persistence.internal.sessions.ObjectChangeSet calculateChangesForExistingObject(Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet changeSet, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor, boolean shouldRaiseEvent)
      INTERNAL: PERF: Calculate change for the new object, avoids check for new since already know.
      Specified by:
      calculateChangesForExistingObject in interface ObjectChangePolicy
      Parameters:
      clone - the Object to compute a change set for
      changeSet - the change set to add changes to
      unitOfWork - the current session
      descriptor - the descriptor for this object
      shouldRaiseEvent - indicates whether PreUpdate event should be risen (usually true)
      Returns:
      ObjectChangeSet an object change set describing the changes to this object
    • calculateChanges

      public org.eclipse.persistence.internal.sessions.ObjectChangeSet calculateChanges(Object clone, Object backUp, boolean isNew, org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet changeSet, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor, boolean shouldRaiseEvent)
      INTERNAL: calculateChanges creates a change set for a particular object. In DeferredChangeDetectionPolicy all mappings will be compared against a backup copy of the object.
      Specified by:
      calculateChanges in interface ObjectChangePolicy
      Parameters:
      clone - the Object to compute a change set for
      backUp - the old version of the object to use for comparison
      changeSet - the change set to add changes to
      unitOfWork - the current session
      descriptor - the descriptor for this object
      shouldRaiseEvent - indicates whether PreUpdate event should be risen (usually true)
      isNew - determines if the object is new
      Returns:
      an object change set describing the changes to this object
    • clearChanges

      public void clearChanges(Object object, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, ClassDescriptor descriptor, boolean forRefresh)
      INTERNAL: This is a place holder for reseting the listener on one of the subclasses
      Specified by:
      clearChanges in interface ObjectChangePolicy
    • createObjectChangeSet

      public org.eclipse.persistence.internal.sessions.ObjectChangeSet createObjectChangeSet(Object clone, Object backUp, org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet changeSet, boolean isNew, org.eclipse.persistence.internal.sessions.AbstractSession session, ClassDescriptor descriptor)
      INTERNAL: Create ObjectChangeSet
    • createObjectChangeSetThroughComparison

      public org.eclipse.persistence.internal.sessions.ObjectChangeSet createObjectChangeSetThroughComparison(Object clone, Object backUp, org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet changeSet, boolean isNew, org.eclipse.persistence.internal.sessions.AbstractSession session, ClassDescriptor descriptor)
      INTERNAL: Create ObjectChangeSet
      Specified by:
      createObjectChangeSetThroughComparison in interface ObjectChangePolicy
    • dissableEventProcessing

      public void dissableEventProcessing(Object changeTracker)
      INTERNAL: This method is used to disable changetracking temporarily
      Specified by:
      dissableEventProcessing in interface ObjectChangePolicy
    • enableEventProcessing

      public void enableEventProcessing(Object changeTracker)
      INTERNAL: This method is used to enable changetracking temporarily
      Specified by:
      enableEventProcessing in interface ObjectChangePolicy
    • shouldCompareExistingObjectForChange

      public boolean shouldCompareExistingObjectForChange(Object object, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor)
      INTERNAL: Return true if the Object should be compared, false otherwise. In DeferredChangeDetectionPolicy, true is always returned since always allow the UnitOfWork to calculate changes.
      Specified by:
      shouldCompareExistingObjectForChange in interface ObjectChangePolicy
      Parameters:
      object - the object that will be compared
      unitOfWork - the active unitOfWork
      descriptor - the descriptor for the current object
    • buildBackupClone

      public Object buildBackupClone(Object clone, org.eclipse.persistence.internal.descriptors.ObjectBuilder builder, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow)
      INTERNAL: Build back up clone. Used if clone is new because listener should not be set.
      Specified by:
      buildBackupClone in interface ObjectChangePolicy
    • setAggregateChangeListener

      public void setAggregateChangeListener(Object parent, Object aggregate, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, ClassDescriptor descriptor, String mappingAttribute)
      INTERNAL: Assign ChangeListener to an aggregate object
      Specified by:
      setAggregateChangeListener in interface ObjectChangePolicy
    • setChangeListener

      public PropertyChangeListener setChangeListener(Object clone, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, ClassDescriptor descriptor)
      INTERNAL: Set ChangeListener for the clone
      Specified by:
      setChangeListener in interface ObjectChangePolicy
    • setChangeSetOnListener

      public void setChangeSetOnListener(org.eclipse.persistence.internal.sessions.ObjectChangeSet objectChangeSet, Object clone)
      INTERNAL: Set the ObjectChangeSet on the Listener, initially used for aggregate support
      Specified by:
      setChangeSetOnListener in interface ObjectChangePolicy
    • updateWithChanges

      public void updateWithChanges(Object clone, org.eclipse.persistence.internal.sessions.ObjectChangeSet objectChangeSet, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, ClassDescriptor descriptor)
      INTERNAL: Clear changes in the ChangeListener of the clone
      Specified by:
      updateWithChanges in interface ObjectChangePolicy
    • raiseInternalPropertyChangeEvent

      public void raiseInternalPropertyChangeEvent(Object source, String propertyName, Object oldValue, Object newValue)
      INTERNAL: This may cause a property change event to be raised to a listener in the case that a listener exists. If there is no listener then this call is a no-op
      Specified by:
      raiseInternalPropertyChangeEvent in interface ObjectChangePolicy
    • revertChanges

      public void revertChanges(Object clone, ClassDescriptor descriptor, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl uow, Map cloneMapping, boolean forRefresh)
      INTERNAL: This method is used to revert an object within the unit of work
      Specified by:
      revertChanges in interface ObjectChangePolicy
      Parameters:
      cloneMapping - may not be the same as what is in the uow
    • initialize

      public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session, ClassDescriptor descriptor)
      INTERNAL: initialize the Policy
      Specified by:
      initialize in interface ObjectChangePolicy
    • isDeferredChangeDetectionPolicy

      public boolean isDeferredChangeDetectionPolicy()
      Used to track instances of the change policies without doing an instance of check
      Specified by:
      isDeferredChangeDetectionPolicy in interface ObjectChangePolicy
    • isObjectChangeTrackingPolicy

      public boolean isObjectChangeTrackingPolicy()
      Used to track instances of the change policies without doing an instance of check
      Specified by:
      isObjectChangeTrackingPolicy in interface ObjectChangePolicy
    • isAttributeChangeTrackingPolicy

      public boolean isAttributeChangeTrackingPolicy()
      Used to track instances of the change policies without doing an instance of check
      Specified by:
      isAttributeChangeTrackingPolicy in interface ObjectChangePolicy
    • updateListenerForSelfMerge

      public void updateListenerForSelfMerge(org.eclipse.persistence.internal.descriptors.changetracking.ObjectChangeListener listener, ForeignReferenceMapping mapping, Object source, Object target, org.eclipse.persistence.internal.sessions.UnitOfWorkImpl unitOfWork)
      INTERNAL: In cases where a relationship with detached or new entities is merged into itself previous changes may have been recorded for the detached/new entity that need to be updated.
      Specified by:
      updateListenerForSelfMerge in interface ObjectChangePolicy