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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<ObjectChangeSet,ObjectChangeSet>
aggregateChangeSets
protected Map<ObjectChangeSet,ObjectChangeSet>
allChangeSets
protected Map<Object,ObjectChangeSet>
cloneToObjectChangeSet
protected Map<ObjectChangeSet,ObjectChangeSet>
deletedObjects
protected boolean
hasChanges
This attribute is set to true if a changeSet with changes has been addedprotected boolean
hasForcedChanges
protected boolean
isChangeSetFromOutsideUOW
Flag set when calling commitToDatabaseWithPreBuiltChangeSet so we are aware the UOW does not contain the changes from this change set.protected Map<Class,Map<ObjectChangeSet,ObjectChangeSet>>
newObjectChangeSets
protected Map<Class,Map<ObjectChangeSet,ObjectChangeSet>>
objectChanges
This is the collection of ObjectChanges held by this ChangeSetprotected Map<ObjectChangeSet,Object>
objectChangeSetToUOWClone
protected AbstractSession
session
Stores unit of work before it is serialized.
-
Constructor Summary
Constructors Constructor Description UnitOfWorkChangeSet()
INTERNAL: Create a ChangeSetUnitOfWorkChangeSet(AbstractSession session)
INTERNAL: Create a ChangeSet
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDeletedObject(Object object, AbstractSession session)
INTERNAL: Add the Deleted object to the changeSet.void
addDeletedObjects(Map deletedObjects, AbstractSession session)
INTERNAL: Add the Deleted objects to the changeSet.protected void
addNewObjectChangeSet(ObjectChangeSet objectChanges, AbstractSession session)
INTERNAL: Add to the changes for 'object' object to this changeSet.void
addObjectChangeSet(ObjectChangeSet objectChanges, AbstractSession session, boolean forceToNewObjectList)
INTERNAL: Add to the changes for 'object' object to this changeSet.void
addObjectChangeSetForIdentity(ObjectChangeSet objectChanges, Object object)
INTERNAL: Add change records to the lists used to maintain identity.UnitOfWorkChangeSet
buildCacheCoordinationMergeChangeSet(AbstractSession session)
INTERNAL: Return a new UnitOfWorkChangeSet that only includes data require for the remote merge, for cache coordination.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.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.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 ChangeSetSet<ClassDescriptor>
findUpdatedObjectsClasses()
INTERNAL: Returns the set of classes corresponding to updated objects in objectChanges.Map<ObjectChangeSet,ObjectChangeSet>
getAggregateChangeSets()
INTERNAL: Get the Aggregate list.Map<ObjectChangeSet,ObjectChangeSet>
getAllChangeSets()
INTERNAL: This method returns a reference to the collection.Map<Object,ObjectChangeSet>
getCloneToObjectChangeSet()
INTERNAL: Get the clone to object change hash table.Map<ObjectChangeSet,ObjectChangeSet>
getDeletedObjects()
INTERNAL: This method returns the reference to the deleted objects from the changeSet.Map<Class,Map<ObjectChangeSet,ObjectChangeSet>>
getNewObjectChangeSets()
INTERNAL: This method will return a reference to the new object change set collections.Map<Class,Map<ObjectChangeSet,ObjectChangeSet>>
getObjectChanges()
INTERNAL: Returns the ObjectChanges held by this ChangeSet.ObjectChangeSet
getObjectChangeSetForClone(Object clone)
ADVANCED: Get ChangeSet for a particular cloneprotected Map<ObjectChangeSet,Object>
getObjectChangeSetToUOWClone()
INTERNAL: This method returns a reference to the collectionAbstractSession
getSession()
Return the session.Object
getUOWCloneForObjectChangeSet(ObjectChangeSet changeSet)
ADVANCED: This method returns the Clone for a particular changeSetboolean
hasChanges()
INTERNAL: Returns true if the Unit Of Work change Set has changesboolean
hasDeletedObjects()
INTERNAL: Returns true if any deleted objects.boolean
hasForcedChanges()
INTERNAL: Returns true if this uowChangeSet contains an objectChangeSet that has forced SQL changes.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 UOWObjectChangeSet
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 changesetvoid
mergeUnitOfWorkChangeSet(UnitOfWorkChangeSet mergeFromChangeSet, AbstractSession session, boolean postCommit)
INTERNAL: THis method will be used to merge another changeset into this changeset.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.void
removeObjectChangeSet(ObjectChangeSet changeSet)
INTERNAL: Add the changed Object's records to the ChangeSet.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 objectChangesListvoid
setAllChangeSets(Map allChangeSets)
INTERNAL: Sets the collection of ObjectChanges in the change Set.void
setCloneToObjectChangeSet(Map<Object,ObjectChangeSet> cloneToObjectChangeSet)
INTERNAL: This method is used to set the map for cloneToObject reference.void
setDeletedObjects(Map deletedObjects)
INTERNAL: Sets the collection of deleted objects.void
setHasChanges(boolean flag)
INTERNAL: Set whether the Unit Of Work change Set has changesvoid
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 UOWprotected void
setObjectChanges(Map objectChanges)
INTERNAL: Sets the collection of ObjectChanges in the change Set.void
setObjectChangeSetToUOWClone(Map<ObjectChangeSet,Object> objectChangeSetToUOWClone)
INTERNAL: This method is used to insert a new collection into the UOWChangeSet.void
setSession(AbstractSession session)
INTERNAL: Set the session.
-
-
-
Field Detail
-
objectChanges
protected Map<Class,Map<ObjectChangeSet,ObjectChangeSet>> objectChanges
This is the collection of ObjectChanges held by this ChangeSet
-
newObjectChangeSets
protected Map<Class,Map<ObjectChangeSet,ObjectChangeSet>> newObjectChangeSets
-
cloneToObjectChangeSet
protected Map<Object,ObjectChangeSet> cloneToObjectChangeSet
-
objectChangeSetToUOWClone
protected Map<ObjectChangeSet,Object> objectChangeSetToUOWClone
-
aggregateChangeSets
protected Map<ObjectChangeSet,ObjectChangeSet> aggregateChangeSets
-
allChangeSets
protected Map<ObjectChangeSet,ObjectChangeSet> allChangeSets
-
deletedObjects
protected Map<ObjectChangeSet,ObjectChangeSet> deletedObjects
-
hasChanges
protected boolean hasChanges
This attribute is set to true if a changeSet with changes has been added
-
hasForcedChanges
protected boolean hasForcedChanges
-
isChangeSetFromOutsideUOW
protected boolean isChangeSetFromOutsideUOW
Flag set when calling commitToDatabaseWithPreBuiltChangeSet so we are aware the UOW does not contain the changes from this change set.
-
session
protected transient AbstractSession session
Stores unit of work before it is serialized.
-
-
Constructor Detail
-
UnitOfWorkChangeSet
public UnitOfWorkChangeSet()
INTERNAL: Create a ChangeSet
-
UnitOfWorkChangeSet
public UnitOfWorkChangeSet(AbstractSession session)
INTERNAL: Create a ChangeSet
-
-
Method Detail
-
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:
addObjectChangeSetForIdentity(ObjectChangeSet, Object)
-
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:
addObjectChangeSetForIdentity(ObjectChangeSet, Object)
-
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:
addObjectChangeSet(ObjectChangeSet, AbstractSession, boolean)
-
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 interfaceUnitOfWorkChangeSet
- 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 interfaceUnitOfWorkChangeSet
- 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 interfaceUnitOfWorkChangeSet
- 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 interfaceUnitOfWorkChangeSet
- 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 interfaceUnitOfWorkChangeSet
- 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.
-
-