private final class TemporaryBuffer.ReversibleBulkDelete extends RecordBuffer.AbstractBulkReversible
Reversible
which on rollback
reverses a bulk record delete action by setting the multiplex ID for
the targeted DMO's back to its original value.Modifier and Type | Field and Description |
---|---|
private java.lang.Object[] |
args
The arguments for the where clause.
|
private int |
delMPID
The multiplex ID used to mark the records as deleted.
|
private boolean |
forceDelete
Force record deletion instead of updating the multiplex ID.
|
private boolean |
hasWhere
Flag indicating if this bulk delete had a where clause or not.
|
private java.io.Serializable |
key
If not-null, it represents the record which we want to rollback or
delete, only if it satisfies the where clause.
|
private org.hibernate.type.Type[] |
types
The associated type for each argument.
|
private java.lang.String |
where
The where clause representing the records to be deleted.
|
LOG
Constructor and Description |
---|
ReversibleBulkDelete(int delMPID,
boolean hasWhere)
Constructor.
|
ReversibleBulkDelete(int delMPID,
java.io.Serializable key)
Constructor to rollback a record which may deleted during a bulk
action.
|
ReversibleBulkDelete(java.lang.String where,
java.lang.Object[] args,
org.hibernate.type.Type[] types,
int delMPID)
This constructor will limit the bulk delete to the where clause, if
if specified.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
containsRecord(java.io.Serializable id)
This method checks if this bulk reversible has deleted the record with the given key.
|
(package private) Reversible |
duplicate(java.io.Serializable key)
Duplicate this reversible action.
|
private int |
executeQuery(java.lang.StringBuilder buf)
Execute an update or delete statement.
|
private void |
forceDelete()
Remove the marked records from the table.
|
protected Persistable |
getDMO()
No-op.
|
protected java.lang.String |
getDMOName()
Get the unqualified interface name of the DMO being managed by this
reversible.
|
protected java.io.Serializable |
getId()
No-op.
|
protected void |
rollback(boolean rollForward,
boolean transaction)
Reverse the bulk deletion of the records which meet the specified
criteria, by setting back their multiplex ID to a positive value.
|
protected void |
setDMO(Persistable dmo)
Set the underlying DMO for this reversible action.
|
(package private) void |
setForceDelete(boolean forceDelete)
Set the
forceDelete flag: when true , the
records which satisfy the where clause (if any) will be deleted. |
protected boolean |
storesDMO()
Indicate whether this
Reversible implementation stores its
DMO locally, as opposed to storing an identifier and having to retrieve
the DMO from the backing database, or not making a DMO available at all. |
private java.lang.String |
tableOrClassName()
Return the table or DMO implementation class name, depending on whether we will roll
back the bulk delete using SQL or HQL.
|
java.lang.String |
toString()
Get a string representation of the internal state of this object,
primarily for debugging purposes.
|
getAction, isNewlyCreated, prepareRollback, setNewlyCreated
private final int delMPID
private final java.io.Serializable key
private java.lang.String where
private java.lang.Object[] args
private org.hibernate.type.Type[] types
private boolean forceDelete
private boolean hasWhere
ReversibleBulkDelete(int delMPID, boolean hasWhere)
delMPID
- The multiplex ID value used to mark those records as deletedhasWhere
- Flag indicating if this bulk delete had a where clause.ReversibleBulkDelete(java.lang.String where, java.lang.Object[] args, org.hibernate.type.Type[] types, int delMPID)
delMPID
will specify the actual multiplex ID for
the records which should be deleted.where
- The conditions which targets the deleted records. May be
null.args
- The needed arguments for the where
clause. May
be null.types
- The associated type for each argument. May be null.delMPID
- The multiplex ID value used to mark those records as deletedReversibleBulkDelete(int delMPID, java.io.Serializable key)
delMPID
- the multiplex ID value used to mark those records as deletedkey
- The key for the record which we want to delete or rollback.public java.lang.String toString()
toString
in class Reversible
protected boolean containsRecord(java.io.Serializable id)
containsRecord
in class RecordBuffer.AbstractBulkReversible
id
- Primary key of the record to be checked.true
if the record was deleted by this bulk
reversible.protected boolean storesDMO()
Reversible
implementation stores its
DMO locally, as opposed to storing an identifier and having to retrieve
the DMO from the backing database, or not making a DMO available at all.storesDMO
in class Reversible
true
if the DMO is stored locally, else
false
.protected java.lang.String getDMOName()
getDMOName
in class Reversible
void setForceDelete(boolean forceDelete)
forceDelete
flag: when true
, the
records which satisfy the where
clause (if any) will be deleted.forceDelete
- The new forceDelete flag as explained above.protected java.io.Serializable getId()
getId
in class Reversible
java.lang.UnsupportedOperationException
- No DMO is required for a bulk delete.Reversible duplicate(java.io.Serializable key)
duplicate
in class Reversible
key
- The key to set for the new reversible action.protected Persistable getDMO()
getDMO
in class Reversible
java.lang.UnsupportedOperationException
- always; no DMO is required for a bulk delete.protected void setDMO(Persistable dmo)
setDMO
in class Reversible
dmo
- The underlying DMO.protected void rollback(boolean rollForward, boolean transaction) throws PersistenceException
If forceDelete
is set to true
, this method
will actually force the deletion of the records which satisfy the
where
clause (if any) and have the specified multiplex
ID.
rollback
in class Reversible
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 updating the records.private int executeQuery(java.lang.StringBuilder buf) throws PersistenceException
buf
- The string used to construct the statement.PersistenceException
- if an error occurs at the database or in the persistence
layer when updating or deleting the records.private void forceDelete() throws PersistenceException
PersistenceException
- if an error occurs at the database or in the persistence
layer when deleting the records.private java.lang.String tableOrClassName()