private final class RecordBuffer.ReversibleUpdate extends AbstractReversible
Reversible
which on rollback
reverses one or more updates made to a record's properties.Modifier and Type | Class and Description |
---|---|
private class |
RecordBuffer.ReversibleUpdate.Key
Custom map key for the enclosing class' rollback map.
|
Modifier and Type | Field and Description |
---|---|
private java.util.Map<RecordBuffer.ReversibleUpdate.Key,java.lang.Object> |
rollbackMap
Map of property key to original value
|
private boolean |
uniqueConstraints
Flag indicating if this update touches any property which is part
of an unique constraint.
|
LOG
Constructor and Description |
---|
ReversibleUpdate()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
addUndoEntry(java.lang.String property,
java.lang.Integer index,
java.lang.Object oldValue)
Add an undo entry to the rollback map.
|
protected java.lang.String |
getAction()
Get a string which briefly describes the action which this object
will reverse upon rollback.
|
(package private) void |
nonDestructiveMerge(RecordBuffer.ReversibleUpdate source)
Merge all undo entries from a source instance of this class to this
instance.
|
protected void |
rollbackWorker(boolean rollForward,
boolean transaction)
Reverse all updates made to the target DMO by invoking setter methods to set back all
original property values known to this object.
|
java.lang.String |
toString()
Overridden implementation which adds a dump of the rollback map of
undo entries to the parent's display.
|
getBuffer, getDMO, getDMOName, getId, getIdentifier, isNullDMOAllowed, prepareRollback, rollback, setDMO, storesDMO
duplicate, isNewlyCreated, setNewlyCreated
private final java.util.Map<RecordBuffer.ReversibleUpdate.Key,java.lang.Object> rollbackMap
private boolean uniqueConstraints
public java.lang.String toString()
toString
in class Reversible
protected java.lang.String getAction()
getAction
in class Reversible
protected void rollbackWorker(boolean rollForward, boolean transaction) throws PersistenceException
rollbackWorker
in class AbstractReversible
rollForward
- If true
, this method is being invoked in order
to re-roll forward a non-undoable change, after a
database-level rollback. This indicates the modification is
made within a new transaction invoked after the
database-level rollback.
If false
, this method is being invoked in order
to roll back an undoable change within the context of an
application-level, full transaction or sub-transaction
rollback.transaction
- true
if this rollback occurs at a full
transaction boundary, else false
.PersistenceException
- if an error occurs at the database or in the persistence
layer when rolling back record updates.void addUndoEntry(java.lang.String property, java.lang.Integer index, java.lang.Object oldValue)
null
for simple properties). The value
of the map entry is the original value to which the property will be
rolled back if necessary.
If an entry already exists for the given key, it is not replaced. Thus, multiple changes to the same property are collapsed such that a rollback actually rolls back to the original valud of the property, not to an intermediate state.
property
- Name of updated property.index
- Zero-based index for an indexed property; should be
null
for a simple property.oldValue
- Value to which the property should be rolled back.void nonDestructiveMerge(RecordBuffer.ReversibleUpdate source)
source
's rollback map, the entry within
source
is ignored.source
- Source object from which to merge undo entries.