Top Description Inners Fields Constructors Methods
org.eclipse.persistence.internal.sessions

public Class ObjectChangeSet

extends Object
implements Serializable, Comparable<ObjectChangeSet>, ObjectChangeSet
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.sessions.changesets.ObjectChangeSet, java.lang.Comparable, java.io.Serializable
Known Direct Subclasses
org.eclipse.persistence.internal.sessions.AggregateObjectChangeSet
Imports
java.io.Serializable, java.util.ArrayList, .Comparator, .HashMap, .HashSet, .List, .Map, .Set, org.eclipse.persistence.descriptors.ClassDescriptor, .FetchGroupManager, .TimestampLockingPolicy, .VersionLockingPolicy, org.eclipse.persistence.internal.core.helper.CoreClassConstants, org.eclipse.persistence.internal.descriptors.OptimisticLockingPolicy, org.eclipse.persistence.internal.helper.ClassConstants, org.eclipse.persistence.internal.identitymaps.CacheKey, org.eclipse.persistence.logging.SessionLog, org.eclipse.persistence.mappings.DatabaseMapping, org.eclipse.persistence.mappings.foundation.AbstractDirectMapping, org.eclipse.persistence.queries.FetchGroup, .ReadObjectQuery

Purpose: Hold the Records of change for a particular instance of an object.

Description: This class uses the Primary Keys of the Object it represents, and the class.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ObjectChangeSet.ObjectChangeSetComparator

Allow change sets to be compared by changes for batching.

Field Summary

Modifier and TypeField and Description
protected transient CacheKey
activeCacheKey

PERF: Cache the session cacheKey during the merge to avoid duplicate lookups.

protected transient Map<String, ChangeRecord>
protected int
cacheSynchronizationType

Used to store the type of cache synchronization used for this object This variable is set just before the change set is serialized.

protected List<ChangeRecord>
changes

This is the collection of changes

protected String
protected transient Class<?>
protected transient Object
protected transient Set<String>
deferredSet

This is used during attribute level change tracking when a particular change was detected but that change can not be tracked (ie customer set entire collection in object).

protected transient ClassDescriptor
descriptor

Cache the descriptor as it is useful and required in some places.

protected transient boolean
protected transient boolean
hasCmpPolicyForcedUpdate

For CMP only: indicates that the object should be force updated (whether it has OptimisticLocking or not): getCmpPolicy().getForcedUpdate()==true

protected boolean
protected Object
protected Object
protected boolean
protected boolean
isInvalid

Invalid change set shouldn't be merged into object in cache, rather the object should be invalidated

protected boolean
public static final int
protected Object
protected Object
protected transient OptimisticLockingPolicy
optimisticLockingPolicy

Used in mergeObjectChanges method for writeLock and initialWriteLock comparison of the merged change sets

protected AbstractRecord
protected boolean
protected Boolean
shouldModifyVersionField

Contains optimisticReadLockObject corresponding to the clone, non-null indicates forced changes

protected transient boolean
shouldRecalculateAfterUpdateEvent

return whether this change set should be recalculated after an event changes the object

protected transient UnitOfWorkChangeSet
unitOfWorkChangeSet

This member variable holds the reference to the parent UnitOfWork Change Set

protected Object

Constructor Summary

AccessConstructor and Description
public
ObjectChangeSet()

The default constructor.

public
ObjectChangeSet(Object primaryKey, ClassDescriptor descriptor, Object cloneObject, UnitOfWorkChangeSet parent, boolean isNew)

This constructor is used to create an ObjectChangeSet that represents a regular object.

Method Summary

Modifier and TypeMethod and Description
public void
addChange(ChangeRecord changeRecord)

Add the attribute change record.

public void
clear(boolean clearKeys)

INTERNAL: This method will clear the changerecords from a changeSet

public int
compareTo(ObjectChangeSet
the object to be compared.
changeSet
)

Implements java.lang.Comparable.compareTo.

Determine if the receiver is greater or less than the change set.
public boolean

Returns:

true if this change set should contain all change information, false if only the identity information should be available.
containsChangesFromSynchronization
()

INTERNAL: Convenience method used to query this change set after it has been sent by cache synchronization.

public void
deferredDetectionRequiredOn(String attributeName)

INTERNAL: This method is used during attribute level change tracking when a particular change was detected but that change can not be tracked (ie customer set entire collection in object).

protected void
public boolean
equals(Object
the reference object with which to compare.
object
)

Overrides java.lang.Object.equals.

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.equals.

Ensure change sets with the same primary key are equal.
public boolean
equals(ObjectChangeSet objectChange)

Ensure change sets with the same primary key are equal.

public CacheKey
getActiveCacheKey()

INTERNAL: PERF: Return the session cache-key, cached during the merge.

public Map<K, V>
getAttributesToChanges()

INTERNAL: stores the change records indexed by the attribute names

public int
public List<String>
getChangedAttributeNames()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.getChangedAttributeNames.

ADVANCED: This method will return a collection of the attributes changed in the object.
public List<ChangeRecord>
getChanges()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.getChanges.

INTERNAL: This method returns a reference to the collection of changes within this changeSet.
public ChangeRecord
getChangesForAttributeNamed(String attributeName)

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.getChangesForAttributeNamed.

INTERNAL: returns the change record for the specified attribute name
public String
getClassName()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.getClassName.

ADVANCE: This method returns the class type that this changeSet Represents.
public Class<?>

Returns:

java.lang.Class or null if the class type isn't initialized.
getClassType
()

INTERNAL: This method returns the class type that this changeSet represents.

public Class<?>
getClassType(Session session)

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.getClassType.

ADVANCE: This method returns the class type that this changeSet Represents.
public Set<String>
getDeferredSet()

This set contains the list of attributes that must be calculated at commit time.

public ClassDescriptor
public Object
getId()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.getId.

ADVANCED: This method returns the primary key for the object that this change set represents.
public Object
getInitialWriteLockValue()

INTERNAL: This method is used to return the initial lock value of the object this changeSet represents.

public Object
getNewKey()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.getNewKey.

This method returns the key value that this object will be stored under in it's Respective hashmap.
protected Object
getObjectForMerge(MergeManager mergeManager, AbstractSession session, Object primaryKey, ClassDescriptor descriptor)

INTERNAL: For use within the distributed merge process, this method will get an object from the shared cache using a readlock.

public Object
getOldKey()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.getOldKey.

This method returns the key value that this object was stored under in it's Respective hashmap.
public Object
public Object
public AbstractRecord
public int
public Object
getTargetVersionOfSourceObject(MergeManager mergeManager, AbstractSession session)

INTERNAL: This method is used to return the complex object specified within the change record.

public Object
getTargetVersionOfSourceObject(MergeManager mergeManager, AbstractSession targetSession, boolean
boolean if the object can not be found should it be read in from the database.
shouldRead
)

INTERNAL: This method is used to return the complex object specified within the change record.

public Object
getUnitOfWorkClone()

INTERNAL: Returns the UnitOfWork Clone that this ChangeSet was built for.

public UnitOfWorkChangeSet
getUOWChangeSet()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.getUOWChangeSet.

ADVANCED: This method is used to return the parent UnitOfWorkChangeSet.
public Object
getWriteLockValue()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.getWriteLockValue.

INTERNAL: This method is used to return the lock value of the object this changeSet represents.
public boolean
hasChangeFor(String
the name of the attribute to search for.
attributeName
)

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.hasChangeFor.

ADVANCED: This method will return true if the specified attribute has been changed.
public boolean
hasChanges()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.hasChanges.

ADVANCED: Returns true if this particular changeSet has changes.
public boolean
public boolean
hasDeferredAttributes()

Check to see if there are any attributes that must be calculated at commit time.

public boolean
hasForcedChanges()

INTERNAL: Returns true if this particular changeSet has forced SQL changes.

public boolean
hasForcedChangesFromCascadeLocking()

INTERNAL: Returns true if this particular changeSet has forced SQL changes because of a cascade optimistic locking policy.

public int
hashCode()

Overrides java.lang.Object.hashCode.

This method overrides the hashcode method.
public boolean
hasKeys()

INTERNAL: Returns true if this particular changeSet has a Key.

public boolean
public boolean
public boolean
isAggregate()

INTERNAL: Used to determine if the object change set represents an aggregate object.

public boolean
isInvalid()

INTERNAL: Indicates whether the change set is invalid.

public boolean
isNew()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.isNew.

ADVANCED: Returns true if this ObjectChangeSet represents a new object.
public void
mergeObjectChanges(ObjectChangeSet changeSetToMergeFrom, UnitOfWorkChangeSet mergeToChangeSet, UnitOfWorkChangeSet mergeFromChangeSet)

INTERNAL: This method will be used to merge changes from a supplied ObjectChangeSet into this changeSet.

public void
postSerialize(Object clone, UnitOfWorkChangeSet uowChangeSet, AbstractSession session)

INTERNAL: Reset the change set's transient variables after serialization.

public void
readCompleteChangeSet(ObjectInputStream stream)

INTERNAL: Helper method used by readObject to read a completely serialized change set from the stream.

public void
readIdentityInformation(ObjectInputStream stream)

INTERNAL: Helper method used by readObject to read just the information about object identity from a serialized stream.

private void
readObject(ObjectInputStream stream)

INTERNAL: Override the default serialization.

protected void
rebuildWriteLockValueFromUserFormat(ClassDescriptor descriptor, AbstractSession session)

Rebuild writeLockValue to the expected type from user format i.e XML change set has all values as String.

public void
removeChange(String attributeName)

INTERNAL: Remove the change.

protected void
removeFromIdentityMap(AbstractSession session)

Remove object represent this change set from identity map.

public void
setActiveCacheKey(CacheKey activeCacheKey)

INTERNAL: PERF: Set the session cache-key, cached during the merge.

public void
setCacheSynchronizationType(int cacheSynchronizationType)

public void
setChanges(List<E> changesList)

Set the changes.

public void
setClassName(String newValue)

INTERNAL: Set the class name.

public void
setClassType(Class<?> newValue)

Set the class type.

public void
public void
setHasCmpPolicyForcedUpdate(boolean hasCmpPolicyForcedUpdate)

INTERNAL:

public void
setHasForcedChangesFromCascadeLocking(boolean newValue)

INTERNAL: Used by calculateChanges to mark this ObjectChangeSet as having to be flushed to the db stemming from a cascade optimistic locking policy.

public void
setHasVersionChange(boolean hasVersionChange)

public void
setId(Object id)

Set the id of the object for this change set.

public void
setInitialWriteLockValue(Object initialWriteLockValue)

ADVANCED: This method is used to set the initial writeLock value for an ObjectChangeSet.

public void
setIsAggregate(boolean
boolean true if the ChangeSet represents an aggregate
isAggregate
)

INTERNAL: Set if this object change Set represents an aggregate

public void
setIsInvalid(boolean isInvalid)

public void
setIsNew(boolean
boolean true if this ChangeSet represents a new object
newIsNew
)

INTERNAL: Set whether this ObjectChanges represents a new Object

public void
setNewKey(Object key)

This method is used to set the value that this object will be stored under in its respected map collection

public void
setOldKey(Object key)

This method is used to set the value that this object was stored under in its respected map collection

public void
setOptimisticLockingPolicyAndInitialWriteLockValue(OptimisticLockingPolicy optimisticLockingPolicy, AbstractSession session)

INTERNAL: This method should ONLY be used to set the initial writeLock value for an ObjectChangeSet when it is first built.

public void
public void
setShouldBeDeleted(boolean
boolean
newValue
)

This method was created in VisualAge.

public void
setShouldModifyVersionField(Boolean shouldModifyVersionField)

INTERNAL: Holds a Boolean indicating whether version field should be modified.

public void
setShouldRecalculateAfterUpdateEvent(boolean shouldRecalculateAfterUpdateEvent)

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.setShouldRecalculateAfterUpdateEvent.

ADVANCED Set whether this ObjectChangeSet should be recalculated after changes in event
public void
public void
setUnitOfWorkClone(Object cloneObject)

INTERNAL: Sets the UnitOfWork Clone that this ChangeSet was built for.

public void
setUOWChangeSet(UnitOfWorkChangeSet newUnitOfWorkChangeSet)

INTERNAL: Used to set the parent change Set.

public void
setWriteLockValue(Object newWriteLockValue)

ADVANCED: This method is used to set the writeLock value for an ObjectChangeSet Any changes to the write lock value should to through setWriteLockValue(Object obj) so that the change set is marked as being dirty.

public boolean
shouldBeDeleted()

Mark change set for a deleted object.

public boolean
shouldInvalidateObject(Object
Object is from session's cache into which the changes are about to be merged, non null.
original
,
AbstractSession
AbstractSession into which the changes are about to be merged;
session
)

INTERNAL: Indicates whether the object in session cache should be invalidated.

public Boolean
shouldModifyVersionField()

INTERNAL: Holds a Boolean indicating whether version field should be modified.

public boolean
shouldRecalculateAfterUpdateEvent()

Implements org.eclipse.persistence.sessions.changesets.ObjectChangeSet.shouldRecalculateAfterUpdateEvent.

ADVANCED Returns true if this ObjectChangeSet should be recalculated after changes in event
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
updateChangeRecordForAttribute(String attributeName, Object value)

INTERNAL: Used to update a changeRecord that is stored in the CHangeSet with a new value.

public void
updateChangeRecordForAttribute(DatabaseMapping mapping, Object value, AbstractSession session, Object oldValue)

INTERNAL: Used to update a changeRecord that is stored in the CHangeSet with a new value.

public void
updateChangeRecordForAttributeWithMappedObject(String attributeName, Object value, AbstractSession session)

ADVANCED: Used to update a changeRecord that is stored in the CHangeSet with a new value.

public void
updateReferences(UnitOfWorkChangeSet localChangeSet, UnitOfWorkChangeSet mergingChangeSet)

INTERNAL: This method will be used when merging changesets into other changesets.

protected void
public void
writeCompleteChangeSet(ObjectOutputStream stream)

INTERNAL: Helper method to readObject.

public void
writeIdentityInformation(ObjectOutputStream stream)

INTERNAL: Helper method to writeObject.

private void
writeObject(ObjectOutputStream stream)

INTERNAL: Override the default serialization since different parts of an ObjectChangeSet will be serialized depending on the type of CacheSynchronizationType

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait