Class UnitOfWorkChangeSet

java.lang.Object
org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet
All Implemented Interfaces:
Serializable, UnitOfWorkChangeSet

public class UnitOfWorkChangeSet extends Object implements Serializable, UnitOfWorkChangeSet

Purpose: This is the overall collection of changes.

Description: It holds all of the object changes and all ObjectChanges, with the same classType and primary keys, referenced in a changeSet should be the same object.

See Also:
  • Field Details

  • Constructor Details

    • UnitOfWorkChangeSet

      public UnitOfWorkChangeSet()
      INTERNAL: Create a ChangeSet
    • UnitOfWorkChangeSet

      public UnitOfWorkChangeSet(AbstractSession session)
      INTERNAL: Create a ChangeSet
  • Method Details

    • getSession

      public AbstractSession getSession()
      Return the session. This only exists before serialization.
    • setSession

      public void setSession(AbstractSession session)
      INTERNAL: Set the session. This only exists before serialization.
    • addDeletedObjects

      public void addDeletedObjects(Map deletedObjects, AbstractSession session)
      INTERNAL: Add the Deleted objects to the changeSet.
    • addDeletedObject

      public void addDeletedObject(Object object, AbstractSession session)
      INTERNAL: Add the Deleted object to the changeSet.
    • addObjectChangeSet

      public void addObjectChangeSet(ObjectChangeSet objectChanges, AbstractSession session, boolean forceToNewObjectList)
      INTERNAL: Add to the changes for 'object' object to this changeSet. This method will not add to the lists that are used for identity lookups. The passed change set *must* either have changes or forced changes.
      Parameters:
      forceToNewObjectList - - Any pre commit actions should pass in true since new objects have extra-handling. Anything post commit, pass in false.
      See Also:
    • addNewObjectChangeSet

      protected void addNewObjectChangeSet(ObjectChangeSet objectChanges, AbstractSession session)
      INTERNAL: Add to the changes for 'object' object to this changeSet. This method will not add to the lists that are used for identity lookups. It is called specifically for new objects, and new object will be moved to the standard changes list by the QueryMechanism after insert.
      Parameters:
      objectChanges - the new object change set
      See Also:
    • findObjectChangeSet

      public ObjectChangeSet findObjectChangeSet(ObjectChangeSet changeSet, UnitOfWorkChangeSet mergeFromChangeSet)
      INTERNAL: This method can be used find the equivalent changeset within this UnitOfWorkChangeSet Aggregates, and new objects without primaryKeys from serialized ChangeSets will not be found Which may result in duplicates, in the UnitOfWorkChangeSet.
    • findOrIntegrateObjectChangeSet

      public ObjectChangeSet findOrIntegrateObjectChangeSet(ObjectChangeSet tofind, UnitOfWorkChangeSet mergeFromChangeSet)
      INTERNAL: This method will be used during the merge process to either find an equivalent change set within this UnitOfWorkChangeSet or integrate that changeset into this UOW ChangeSet
    • findOrCreateLocalObjectChangeSet

      public ObjectChangeSet findOrCreateLocalObjectChangeSet(Object entityClone, ClassDescriptor descriptor, boolean isNew)
      INTERNAL" This method is used during the merge process to either find the existing ChangeSet or create a new one.
    • addObjectChangeSetForIdentity

      public void addObjectChangeSetForIdentity(ObjectChangeSet objectChanges, Object object)
      INTERNAL: Add change records to the lists used to maintain identity. This will not actually add the changes to 'object' to the change set.
      Parameters:
      objectChanges - prototype.changeset.ObjectChanges
      See Also:
    • getAggregateChangeSets

      public Map<ObjectChangeSet,ObjectChangeSet> getAggregateChangeSets()
      INTERNAL: Get the Aggregate list. Lazy initializes the map if required.
    • getAllChangeSets

      public Map<ObjectChangeSet,ObjectChangeSet> getAllChangeSets()
      INTERNAL: This method returns a reference to the collection.
      Specified by:
      getAllChangeSets in interface UnitOfWorkChangeSet
      Returns:
      Map
    • buildCacheCoordinationMergeChangeSet

      public UnitOfWorkChangeSet buildCacheCoordinationMergeChangeSet(AbstractSession session)
      INTERNAL: Return a new UnitOfWorkChangeSet that only includes data require for the remote merge, for cache coordination.
      Parameters:
      session - current database session
    • getCloneToObjectChangeSet

      public Map<Object,ObjectChangeSet> getCloneToObjectChangeSet()
      INTERNAL: Get the clone to object change hash table. Lazy initializes the map if required.
    • getDeletedObjects

      public Map<ObjectChangeSet,ObjectChangeSet> getDeletedObjects()
      INTERNAL: This method returns the reference to the deleted objects from the changeSet.
      Specified by:
      getDeletedObjects in interface UnitOfWorkChangeSet
      Returns:
      Map
    • getObjectChanges

      public Map<Class<?>,Map<ObjectChangeSet,ObjectChangeSet>> getObjectChanges()
      INTERNAL: Returns the ObjectChanges held by this ChangeSet.
    • findUpdatedObjectsClasses

      public Set<ClassDescriptor> findUpdatedObjectsClasses()
      INTERNAL: Returns the set of classes corresponding to updated objects in objectChanges.
    • getObjectChangeSetForClone

      public ObjectChangeSet getObjectChangeSetForClone(Object clone)
      ADVANCED: Get ChangeSet for a particular clone
      Specified by:
      getObjectChangeSetForClone in interface UnitOfWorkChangeSet
      Returns:
      ObjectChangeSet the changeSet that represents a particular clone
    • getObjectChangeSetToUOWClone

      protected Map<ObjectChangeSet,Object> getObjectChangeSetToUOWClone()
      INTERNAL: This method returns a reference to the collection
      Returns:
      Map
    • getUOWCloneForObjectChangeSet

      public Object getUOWCloneForObjectChangeSet(ObjectChangeSet changeSet)
      ADVANCED: This method returns the Clone for a particular changeSet
      Specified by:
      getUOWCloneForObjectChangeSet in interface UnitOfWorkChangeSet
      Returns:
      Object the clone represented by the changeSet
    • hasChanges

      public boolean hasChanges()
      INTERNAL: Returns true if the Unit Of Work change Set has changes
      Specified by:
      hasChanges in interface UnitOfWorkChangeSet
      Returns:
      boolean
    • hasDeletedObjects

      public boolean hasDeletedObjects()
      INTERNAL: Returns true if any deleted objects. This should be used before accessing deleted object to avoid creation of map.
    • setHasChanges

      public void setHasChanges(boolean flag)
      INTERNAL: Set whether the Unit Of Work change Set has changes
    • hasForcedChanges

      public boolean hasForcedChanges()
      INTERNAL: Returns true if this uowChangeSet contains an objectChangeSet that has forced SQL changes. This is true whenever CMPPolicy.getForceUpdate() == true.
      Returns:
      boolean
    • mergeObjectChanges

      public ObjectChangeSet mergeObjectChanges(ObjectChangeSet objectChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)
      INTERNAL: This method will be used to merge a change set into an UnitOfWorkChangeSet This method returns the local instance of the changeset
    • mergeUnitOfWorkChangeSet

      public void mergeUnitOfWorkChangeSet(UnitOfWorkChangeSet mergeFromChangeSet, AbstractSession session, boolean postCommit)
      INTERNAL: THis method will be used to merge another changeset into this changeset. The Main use of this method is for non-deferred writes and checkpointing so that the accumulated changes are collected and merged at the end of the transaction.
    • putNewObjectInChangesList

      public void putNewObjectInChangesList(ObjectChangeSet objectChangeSet, AbstractSession session)
      INTERNAL: Used to rehash the new objects back into the objectChanges list for serialization Assumes the transaction in in post commit stage.
    • removeObjectChangeSetFromNewList

      public void removeObjectChangeSetFromNewList(ObjectChangeSet objectChangeSet, AbstractSession session)
      INTERNAL: Used to remove a new object from the new objects list once it has been inserted and added to the objectChangesList
    • removeObjectChangeSet

      public void removeObjectChangeSet(ObjectChangeSet changeSet)
      INTERNAL: Add the changed Object's records to the ChangeSet.
    • setIsChangeSetFromOutsideUOW

      public void setIsChangeSetFromOutsideUOW(boolean isChangeSetFromOutsideUOW)
      INTERNAL: Set the internal flag that tells that this change set was built outside this UOW and the changes it contains cannot be calculated from the contents of this UOW
    • isChangeSetFromOutsideUOW

      public boolean isChangeSetFromOutsideUOW()
      INTERNAL: Get the internal flag that tells that this change set was built outside this UOW and the changes it contains cannot be calculated from the contents of this UOW
    • setCloneToObjectChangeSet

      public void setCloneToObjectChangeSet(Map<Object,ObjectChangeSet> cloneToObjectChangeSet)
      INTERNAL: This method is used to set the map for cloneToObject reference.
    • setObjectChanges

      protected void setObjectChanges(Map objectChanges)
      INTERNAL: Sets the collection of ObjectChanges in the change Set.
    • setAllChangeSets

      public void setAllChangeSets(Map allChangeSets)
      INTERNAL: Sets the collection of ObjectChanges in the change Set.
    • setDeletedObjects

      public void setDeletedObjects(Map deletedObjects)
      INTERNAL: Sets the collection of deleted objects.
    • setObjectChangeSetToUOWClone

      public void setObjectChangeSetToUOWClone(Map<ObjectChangeSet,Object> objectChangeSetToUOWClone)
      INTERNAL: This method is used to insert a new collection into the UOWChangeSet.
    • getNewObjectChangeSets

      public Map<Class<?>,Map<ObjectChangeSet,ObjectChangeSet>> getNewObjectChangeSets()
      INTERNAL: This method will return a reference to the new object change set collections.