public class SavepointReversible extends Reversible
Implementation Notes
Implementation based on two methods: setSavepoint(...) and rollbackSavepoint(). Both methods
use Hibernate Work interface to set/rollback Savepoint to Hibernate connection.
Savepoint could give some problems for the Hibernate second-level cache or for dealing with
any records currently held in buffers. Also Savepoint reversible approach should be tested
for each database type.
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
dmoName
DMO interface short name.
|
private java.lang.String |
operationName
Operation name corresponding to this reversible.
|
private java.sql.Savepoint |
savepoint
Savepoint instance.
|
private org.hibernate.Session |
session
The session which is invoking reversible operation.
|
LOG
Constructor and Description |
---|
SavepointReversible(java.lang.String dmoName,
java.lang.String operationName,
org.hibernate.Session session)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
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 operation.
|
private void |
rollbackSavepoint()
Rollback savepoint for the connection managed by this session.
|
protected void |
setDMO(Persistable dmo)
Set the underlying DMO for this reversible action.
|
private void |
setSavepoint()
Create savepoint for the connection managed by this session.
|
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. |
java.lang.String |
toString()
Get a string representation of the internal state of this object,
primarily for debugging purposes.
|
duplicate, getAction, isNewlyCreated, prepareRollback, setNewlyCreated
private java.lang.String dmoName
private java.lang.String operationName
private java.sql.Savepoint savepoint
private org.hibernate.Session session
public SavepointReversible(java.lang.String dmoName, java.lang.String operationName, org.hibernate.Session session) throws PersistenceException
dmoName
- DMO interface short name.operationName
- Operation name corresponding to this reversible. It would be set as savepoint
name.session
- The session which is invoking reversible operation.PersistenceException
public java.lang.String toString()
toString
in class 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
protected java.io.Serializable getId()
getId
in class Reversible
java.lang.UnsupportedOperationException
- No DMO is required.protected Persistable getDMO()
getDMO
in class Reversible
java.lang.UnsupportedOperationException
- always; no DMO is required.protected void setDMO(Persistable dmo)
setDMO
in class Reversible
dmo
- The underlying DMO.protected void rollback(boolean rollForward, boolean transaction) throws PersistenceException
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 void setSavepoint()
private void rollbackSavepoint()