Class DirectCollectionChangeRecord
- java.lang.Object
-
- org.eclipse.persistence.internal.sessions.ChangeRecord
-
- org.eclipse.persistence.internal.sessions.DeferrableChangeRecord
-
- org.eclipse.persistence.internal.sessions.DirectCollectionChangeRecord
-
- All Implemented Interfaces:
Serializable
,ChangeRecord
,DirectCollectionChangeRecord
public class DirectCollectionChangeRecord extends DeferrableChangeRecord implements DirectCollectionChangeRecord
Purpose: This class holds the record of the changes made to a collection attribute of an object.
Description: Collections must be compared to each other and added and removed objects must be recorded separately.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DirectCollectionChangeRecord.NULL
-
Field Summary
Fields Modifier and Type Field Description protected HashMap
addObjectMap
protected Map
changedIndexes
Used only in case listOrderField != null in the mapping.protected HashMap
commitAddMap
Contains the number of objects that must be inserted to once the value is removed in the database as a delete where value = "value" will remove all instances of that value in the database not just one.protected boolean
isFirstToAdd
protected boolean
isFirstToAddAlreadyInCollection
protected boolean
isFirstToRemove
protected boolean
isFirstToRemoveAlreadyOutCollection
protected int
newSize
protected int
oldSize
protected boolean
orderHasBeenRepaired
Indicates whether IndirectList's order has been repaired.protected HashMap
removeObjectMap
-
Fields inherited from class org.eclipse.persistence.internal.sessions.DeferrableChangeRecord
isDeferred, latestCollection, originalCollection
-
Fields inherited from class org.eclipse.persistence.internal.sessions.ChangeRecord
attribute, mapping, owner
-
-
Constructor Summary
Constructors Constructor Description DirectCollectionChangeRecord()
This default constructor.DirectCollectionChangeRecord(ObjectChangeSet owner)
This constructor returns a changeRecord representing the DirectCollection mapping.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addAdditionChange(Object key, Integer count)
This method takes a single addition value and records it.void
addAdditionChange(HashMap additions, HashMap databaseCount)
This method takes a map of primitive objects and adds them to the add list.void
addRemoveChange(Object key, Integer count)
This method takes a single remove change and integrates it with this changeset.void
addRemoveChange(HashMap additions, HashMap databaseCount)
This method takes a hashtable of primitive objects and adds them to the remove list.void
clearChanges()
Clears info about added / removed objects set by change tracker.void
decrementDatabaseCount(Object object)
Decrement the count for objectVector
getAddObjectList()
ADVANCED: This method returns the list of added objects.HashMap
getAddObjectMap()
This method returns the collection of objects that were added to the collection.Map
getChangedIndexes()
HashMap
getCommitAddMap()
This method returns the collection of objects that were added to the collection.int
getNewSize()
int
getOldSize()
Vector
getRemoveObjectList()
ADVANCED: This method returns the list of removed objects.HashMap
getRemoveObjectMap()
This method returns the collection of objects that were removed from the collection.boolean
hasChanges()
Returns true if the change set has changes.void
incrementDatabaseCount(Object object)
Increment the count for objectvoid
internalRecreateOriginalCollection(Object currentCollection, AbstractSession session)
Recreates the original state of the collection.boolean
isFirstToAddAlreadyInCollection()
boolean
isFirstToRemoveAlreadyOutCollection()
void
mergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)
This method will be used to merge one record into another.boolean
orderHasBeenRepaired()
void
setChangedIndexes(Map changedIndexes)
void
setCommitAddition(Hashtable additions)
This method takes a hashtable of primitives and adds them to the commit list.void
setFirstToAddAlreadyInCollection(boolean flag)
void
setFirstToRemoveAlreadyOutCollection(boolean flag)
void
setNewSize(int size)
void
setOldSize(int size)
void
setOrderHasBeenRepaired(boolean hasBeenRepaired)
void
storeDatabaseCounts(Object collection, ContainerPolicy containerPolicy, AbstractSession session)
This method will iterate over the collection and store the database counts for the objects within the collection, this is used for minimal updates.void
updateReferences(UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)
This method will be used to update the objectsChangeSets references-
Methods inherited from class org.eclipse.persistence.internal.sessions.DeferrableChangeRecord
getLatestCollection, getOldValue, getOldValue, getOriginalCollection, isDeferred, recreateOriginalCollection, setIsDeferred, setLatestCollection, setOriginalCollection
-
Methods inherited from class org.eclipse.persistence.internal.sessions.ChangeRecord
getAttribute, getMapping, getOwner, prepareForSynchronization, setAttribute, setMapping, setOwner, toString, updateChangeRecordWithNewValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.persistence.sessions.changesets.ChangeRecord
getAttribute, getOldValue, getOwner
-
-
-
-
Field Detail
-
addObjectMap
protected HashMap addObjectMap
-
removeObjectMap
protected HashMap removeObjectMap
-
commitAddMap
protected HashMap commitAddMap
Contains the number of objects that must be inserted to once the value is removed in the database as a delete where value = "value" will remove all instances of that value in the database not just one.
-
changedIndexes
protected Map changedIndexes
Used only in case listOrderField != null in the mapping. Maps each object which has been added or removed or which order in the list has changed to an array of two (non-intersecting) sets of indexes - old and new.
-
oldSize
protected int oldSize
-
newSize
protected int newSize
-
isFirstToAddAlreadyInCollection
protected boolean isFirstToAddAlreadyInCollection
-
isFirstToRemoveAlreadyOutCollection
protected boolean isFirstToRemoveAlreadyOutCollection
-
isFirstToAdd
protected boolean isFirstToAdd
-
isFirstToRemove
protected boolean isFirstToRemove
-
orderHasBeenRepaired
protected boolean orderHasBeenRepaired
Indicates whether IndirectList's order has been repaired.
-
-
Constructor Detail
-
DirectCollectionChangeRecord
public DirectCollectionChangeRecord()
This default constructor.
-
DirectCollectionChangeRecord
public DirectCollectionChangeRecord(ObjectChangeSet owner)
This constructor returns a changeRecord representing the DirectCollection mapping.
-
-
Method Detail
-
addAdditionChange
public void addAdditionChange(HashMap additions, HashMap databaseCount)
This method takes a map of primitive objects and adds them to the add list. The map stores the number of times the object is in the list.
-
addAdditionChange
public void addAdditionChange(Object key, Integer count)
This method takes a single addition value and records it.
-
addRemoveChange
public void addRemoveChange(HashMap additions, HashMap databaseCount)
This method takes a hashtable of primitive objects and adds them to the remove list. Each reference in the hashtable lists the number of this object that needs to be removed from the collection.
-
addRemoveChange
public void addRemoveChange(Object key, Integer count)
This method takes a single remove change and integrates it with this changeset.
-
setCommitAddition
public void setCommitAddition(Hashtable additions)
This method takes a hashtable of primitives and adds them to the commit list. This count value provided is the number of instances that will need to be inserted into the database once a remove has occurred. This is only set once for each object type.
-
storeDatabaseCounts
public void storeDatabaseCounts(Object collection, ContainerPolicy containerPolicy, AbstractSession session)
This method will iterate over the collection and store the database counts for the objects within the collection, this is used for minimal updates.
-
incrementDatabaseCount
public void incrementDatabaseCount(Object object)
Increment the count for object
-
decrementDatabaseCount
public void decrementDatabaseCount(Object object)
Decrement the count for object
-
getAddObjectList
public Vector getAddObjectList()
ADVANCED: This method returns the list of added objects.- Specified by:
getAddObjectList
in interfaceDirectCollectionChangeRecord
- Returns:
- java.util.Vector
-
getAddObjectMap
public HashMap getAddObjectMap()
This method returns the collection of objects that were added to the collection.
-
getCommitAddMap
public HashMap getCommitAddMap()
This method returns the collection of objects that were added to the collection.
-
getRemoveObjectList
public Vector getRemoveObjectList()
ADVANCED: This method returns the list of removed objects.- Specified by:
getRemoveObjectList
in interfaceDirectCollectionChangeRecord
- Returns:
- java.util.Vector
-
getRemoveObjectMap
public HashMap getRemoveObjectMap()
This method returns the collection of objects that were removed from the collection.
-
hasChanges
public boolean hasChanges()
Returns true if the change set has changes.
-
mergeRecord
public void mergeRecord(ChangeRecord mergeFromRecord, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)
This method will be used to merge one record into another.- Specified by:
mergeRecord
in classChangeRecord
-
updateReferences
public void updateReferences(UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)
This method will be used to update the objectsChangeSets references- Specified by:
updateReferences
in classChangeRecord
-
setFirstToAddAlreadyInCollection
public void setFirstToAddAlreadyInCollection(boolean flag)
-
isFirstToAddAlreadyInCollection
public boolean isFirstToAddAlreadyInCollection()
-
setFirstToRemoveAlreadyOutCollection
public void setFirstToRemoveAlreadyOutCollection(boolean flag)
-
isFirstToRemoveAlreadyOutCollection
public boolean isFirstToRemoveAlreadyOutCollection()
-
setChangedIndexes
public void setChangedIndexes(Map changedIndexes)
-
getChangedIndexes
public Map getChangedIndexes()
-
setOldSize
public void setOldSize(int size)
-
getOldSize
public int getOldSize()
-
setNewSize
public void setNewSize(int size)
-
getNewSize
public int getNewSize()
-
internalRecreateOriginalCollection
public void internalRecreateOriginalCollection(Object currentCollection, AbstractSession session)
Recreates the original state of the collection.- Specified by:
internalRecreateOriginalCollection
in classDeferrableChangeRecord
-
setOrderHasBeenRepaired
public void setOrderHasBeenRepaired(boolean hasBeenRepaired)
-
orderHasBeenRepaired
public boolean orderHasBeenRepaired()
-
clearChanges
public void clearChanges()
Clears info about added / removed objects set by change tracker.- Specified by:
clearChanges
in classDeferrableChangeRecord
-
-