Top Description Methods
org.eclipse.persistence.descriptors.changetracking

public Interface ObjectChangePolicy

extends Serializable
Known Direct Implementers
org.eclipse.persistence.descriptors.changetracking.DeferredChangeDetectionPolicy
Imports
java.beans.PropertyChangeListener, java.io.Serializable, org.eclipse.persistence.internal.sessions.ObjectChangeSet, .AbstractSession, .UnitOfWorkChangeSet, .UnitOfWorkImpl, org.eclipse.persistence.internal.descriptors.*, org.eclipse.persistence.internal.descriptors.changetracking.ObjectChangeListener, org.eclipse.persistence.mappings.ForeignReferenceMapping, org.eclipse.persistence.descriptors.ClassDescriptor, java.util.*

INTERNAL: Implementers of ObjectChangePolicy implement the code which computes changes sets for the UnitOfWork commit process. An ObjectChangePolicy is stored on an Object's descriptor.
Author
Tom Ware
See Also
DeferredChangeDetectionPolicy, ObjectChangeTrackingPolicy, AttributeChangeTrackingPolicy

Method Summary

Modifier and TypeMethod and Description
public Object
buildBackupClone(Object clone, ObjectBuilder builder, UnitOfWorkImpl uow)

INTERNAL: Build back up clone.

public ObjectChangeSet

Returns:

ObjectChangeSet an object change set describing the changes to this object
calculateChanges
(Object
the object to compute a change set for
clone
,
Object
the object used to compute changes from
backupClone
,
boolean
determines if the object is new
isNew
,
UnitOfWorkChangeSet
the change set to add changes to
changes
,
UnitOfWorkImpl
the current session
unitOfWork
,
ClassDescriptor
the descriptor for this object
descriptor
,
boolean
indicates whether PreUpdate event should be risen (usually true)
shouldRaiseEvent
)

INTERNAL: CalculateChanges creates a change set for an existing object.

public ObjectChangeSet

Returns:

ObjectChangeSet an object change set describing the changes to this object
calculateChangesForExistingObject
(Object
the Object to compute a change set for
clone
,
UnitOfWorkChangeSet
the change set to add changes to
changes
,
UnitOfWorkImpl
the current session
unitOfWork
,
ClassDescriptor
the descriptor for this object
descriptor
,
boolean
indicates whether PreUpdate event should be risen (usually true)
shouldRaiseEvent
)

INTERNAL: CalculateChanges creates a change set for an existing object.

public ObjectChangeSet

Returns:

ObjectChangeSet an object change set describing the changes to this object
calculateChangesForNewObject
(Object
the Object to compute a change set for
clone
,
UnitOfWorkChangeSet
the change set to add changes to
changes
,
UnitOfWorkImpl
the current session
unitOfWork
,
ClassDescriptor
the descriptor for this object
descriptor
,
boolean
indicates whether PreUpdate event should be risen (usually true)
shouldRaiseEvent
)

INTERNAL: CalculateChanges creates a change set for a new object.

public void
clearChanges(Object object, UnitOfWorkImpl uow, ClassDescriptor descriptor, boolean forRefresh)

INTERNAL: This is a place holder for reseting the listener on one of the subclasses

public ObjectChangeSet
createObjectChangeSetThroughComparison(Object clone, Object backUp, UnitOfWorkChangeSet changeSet, boolean isNew, AbstractSession session, ClassDescriptor descriptor)

INTERNAL: Create ObjectChangeSet through comparison.

public void
dissableEventProcessing(Object changeTracker)

INTERNAL: This method is used to disable changetracking temporarily

public void
enableEventProcessing(Object changeTracker)

INTERNAL: This method is used to enable changetracking temporarily

public void
initialize(AbstractSession session, ClassDescriptor descriptor)

INTERNAL: initialize the Policy

public boolean
isAttributeChangeTrackingPolicy()

Used to track instances of the change policies without doing an instance of check

public boolean
isDeferredChangeDetectionPolicy()

Used to track instances of the change policies without doing an instance of check

public boolean
isObjectChangeTrackingPolicy()

Used to track instances of the change policies without doing an instance of check

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.

public void
revertChanges(Object clone, ClassDescriptor descriptor, UnitOfWorkImpl uow, Map<K, V> cloneMapping, boolean forRefresh)

INTERNAL: This method is used to revert an object within the unit of work

public void
setAggregateChangeListener(Object parent, Object aggregate, UnitOfWorkImpl uow, ClassDescriptor descriptor, String mappingAttribute)

INTERNAL: Assign Changelistener to an aggregate object

public PropertyChangeListener
setChangeListener(Object clone, UnitOfWorkImpl uow, ClassDescriptor descriptor)

INTERNAL: Assign appropriate ChangeListener to PropertyChangeListener based on the policy.

public void
setChangeSetOnListener(ObjectChangeSet objectChangeSet, Object clone)

INTERNAL: Set the ObjectChangeSet on the Listener, initially used for aggregate support

public boolean
shouldCompareExistingObjectForChange(Object
the object that will be compared
object
,
UnitOfWorkImpl
the active unitOfWork
unitOfWork
,
ClassDescriptor
the descriptor for the current object
descriptor
)

INTERNAL: Return true if the Object should be compared, false otherwise.

public void
updateListenerForSelfMerge(ObjectChangeListener listener, ForeignReferenceMapping mapping, Object source, Object target, 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.

public void
updateWithChanges(Object clone, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow, ClassDescriptor descriptor)

INTERNAL: This method is used internally to rest the policies back to original state This is used when the clones are to be reused.

Method Detail

buildBackupCloneback to summary
public Object buildBackupClone(Object clone, ObjectBuilder builder, UnitOfWorkImpl uow)

INTERNAL: Build back up clone.

calculateChangesback to summary
public ObjectChangeSet calculateChanges(Object clone, Object backupClone, boolean isNew, UnitOfWorkChangeSet changes, UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor, boolean shouldRaiseEvent)

INTERNAL: CalculateChanges creates a change set for an existing object.

Parameters
clone:Object

the object to compute a change set for

backupClone:Object

the object used to compute changes from

isNew:boolean

determines if the object is new

changes:UnitOfWorkChangeSet

the change set to add changes to

unitOfWork:UnitOfWorkImpl

the current session

descriptor:ClassDescriptor

the descriptor for this object

shouldRaiseEvent:boolean

indicates whether PreUpdate event should be risen (usually true)

Returns:ObjectChangeSet

ObjectChangeSet an object change set describing the changes to this object

calculateChangesForExistingObjectback to summary
public ObjectChangeSet calculateChangesForExistingObject(Object clone, UnitOfWorkChangeSet changes, UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor, boolean shouldRaiseEvent)

INTERNAL: CalculateChanges creates a change set for an existing object.

Parameters
clone:Object

the Object to compute a change set for

changes:UnitOfWorkChangeSet

the change set to add changes to

unitOfWork:UnitOfWorkImpl

the current session

descriptor:ClassDescriptor

the descriptor for this object

shouldRaiseEvent:boolean

indicates whether PreUpdate event should be risen (usually true)

Returns:ObjectChangeSet

ObjectChangeSet an object change set describing the changes to this object

calculateChangesForNewObjectback to summary
public ObjectChangeSet calculateChangesForNewObject(Object clone, UnitOfWorkChangeSet changes, UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor, boolean shouldRaiseEvent)

INTERNAL: CalculateChanges creates a change set for a new object.

Parameters
clone:Object

the Object to compute a change set for

changes:UnitOfWorkChangeSet

the change set to add changes to

unitOfWork:UnitOfWorkImpl

the current session

descriptor:ClassDescriptor

the descriptor for this object

shouldRaiseEvent:boolean

indicates whether PreUpdate event should be risen (usually true)

Returns:ObjectChangeSet

ObjectChangeSet an object change set describing the changes to this object

clearChangesback to summary
public void clearChanges(Object object, UnitOfWorkImpl uow, ClassDescriptor descriptor, boolean forRefresh)

INTERNAL: This is a place holder for reseting the listener on one of the subclasses

createObjectChangeSetThroughComparisonback to summary
public ObjectChangeSet createObjectChangeSetThroughComparison(Object clone, Object backUp, UnitOfWorkChangeSet changeSet, boolean isNew, AbstractSession session, ClassDescriptor descriptor)

INTERNAL: Create ObjectChangeSet through comparison. Used in cases where we need to force change calculation (ie aggregates)

dissableEventProcessingback to summary
public void dissableEventProcessing(Object changeTracker)

INTERNAL: This method is used to disable changetracking temporarily

enableEventProcessingback to summary
public void enableEventProcessing(Object changeTracker)

INTERNAL: This method is used to enable changetracking temporarily

initializeback to summary
public void initialize(AbstractSession session, ClassDescriptor descriptor)

INTERNAL: initialize the Policy

isAttributeChangeTrackingPolicyback to summary
public boolean isAttributeChangeTrackingPolicy()

Used to track instances of the change policies without doing an instance of check

isDeferredChangeDetectionPolicyback to summary
public boolean isDeferredChangeDetectionPolicy()

Used to track instances of the change policies without doing an instance of check

isObjectChangeTrackingPolicyback to summary
public boolean isObjectChangeTrackingPolicy()

Used to track instances of the change policies without doing an instance of check

raiseInternalPropertyChangeEventback to summary
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

revertChangesback to summary
public void revertChanges(Object clone, ClassDescriptor descriptor, UnitOfWorkImpl uow, Map<K, V> cloneMapping, boolean forRefresh)

INTERNAL: This method is used to revert an object within the unit of work

setAggregateChangeListenerback to summary
public void setAggregateChangeListener(Object parent, Object aggregate, UnitOfWorkImpl uow, ClassDescriptor descriptor, String mappingAttribute)

INTERNAL: Assign Changelistener to an aggregate object

setChangeListenerback to summary
public PropertyChangeListener setChangeListener(Object clone, UnitOfWorkImpl uow, ClassDescriptor descriptor)

INTERNAL: Assign appropriate ChangeListener to PropertyChangeListener based on the policy.

setChangeSetOnListenerback to summary
public void setChangeSetOnListener(ObjectChangeSet objectChangeSet, Object clone)

INTERNAL: Set the ObjectChangeSet on the Listener, initially used for aggregate support

shouldCompareExistingObjectForChangeback to summary
public boolean shouldCompareExistingObjectForChange(Object object, UnitOfWorkImpl unitOfWork, ClassDescriptor descriptor)

INTERNAL: Return true if the Object should be compared, false otherwise. This method is implemented to allow run time determination of whether a change set should be computed for an object. In general, calculateChanges() will only be executed in a UnitOfWork if this method returns true.

Parameters
object:Object

the object that will be compared

unitOfWork:UnitOfWorkImpl

the active unitOfWork

descriptor:ClassDescriptor

the descriptor for the current object

updateListenerForSelfMergeback to summary
public void updateListenerForSelfMerge(ObjectChangeListener listener, ForeignReferenceMapping mapping, Object source, Object target, 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.

updateWithChangesback to summary
public void updateWithChanges(Object clone, ObjectChangeSet objectChangeSet, UnitOfWorkImpl uow, ClassDescriptor descriptor)

INTERNAL: This method is used internally to rest the policies back to original state This is used when the clones are to be reused.