public abstract class AbstractTransactionStatus extends Object implements TransactionStatus
TransactionStatus
interface.
Pre-implements the handling of local rollback-only and completed flags, and
delegation to an underlying SavepointManager
.
Also offers the option of a holding a savepoint within the transaction.
Does not assume any specific internal transaction handling, such as an underlying transaction object, and no transaction synchronization mechanism.
setRollbackOnly()
,
isRollbackOnly()
,
setCompleted()
,
isCompleted()
,
getSavepointManager()
,
SimpleTransactionStatus
,
DefaultTransactionStatus
Constructor and Description |
---|
AbstractTransactionStatus() |
Modifier and Type | Method and Description |
---|---|
void |
createAndHoldSavepoint()
Create a savepoint and hold it for the transaction.
|
Object |
createSavepoint()
This implementation delegates to a SavepointManager for the
underlying transaction, if possible.
|
void |
flush()
This implementations is empty, considering flush as a no-op.
|
protected Object |
getSavepoint()
Get the savepoint for this transaction, if any.
|
protected SavepointManager |
getSavepointManager()
Return a SavepointManager for the underlying transaction, if possible.
|
boolean |
hasSavepoint()
Return whether this transaction internally carries a savepoint,
that is, has been created as nested transaction based on a savepoint.
|
boolean |
isCompleted()
Return whether this transaction is completed, that is,
whether it has already been committed or rolled back.
|
boolean |
isGlobalRollbackOnly()
Template method for determining the global rollback-only flag of the
underlying transaction, if any.
|
boolean |
isLocalRollbackOnly()
Determine the rollback-only flag via checking this TransactionStatus.
|
boolean |
isRollbackOnly()
Determine the rollback-only flag via checking both the local rollback-only flag
of this TransactionStatus and the global rollback-only flag of the underlying
transaction, if any.
|
void |
releaseHeldSavepoint()
Release the savepoint that is held for the transaction.
|
void |
releaseSavepoint(Object savepoint)
This implementation delegates to a SavepointManager for the
underlying transaction, if possible.
|
void |
rollbackToHeldSavepoint()
Roll back to the savepoint that is held for the transaction
and release the savepoint right afterwards.
|
void |
rollbackToSavepoint(Object savepoint)
This implementation delegates to a SavepointManager for the
underlying transaction, if possible.
|
void |
setCompleted()
Mark this transaction as completed, that is, committed or rolled back.
|
void |
setRollbackOnly()
Set the transaction rollback-only.
|
protected void |
setSavepoint(Object savepoint)
Set a savepoint for this transaction.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isNewTransaction
public void setRollbackOnly()
TransactionStatus
This is mainly intended for transactions managed by
TransactionTemplate
or
TransactionInterceptor
,
where the actual commit/rollback decision is made by the container.
public boolean isRollbackOnly()
isRollbackOnly
in interface TransactionStatus
isLocalRollbackOnly()
,
isGlobalRollbackOnly()
public boolean isLocalRollbackOnly()
Will only return "true" if the application called setRollbackOnly
on this TransactionStatus object.
public boolean isGlobalRollbackOnly()
This implementation always returns false
.
public void flush()
flush
in interface Flushable
flush
in interface TransactionStatus
public void setCompleted()
public boolean isCompleted()
TransactionStatus
protected void setSavepoint(Object savepoint)
TransactionDefinition.PROPAGATION_NESTED
protected Object getSavepoint()
public boolean hasSavepoint()
TransactionStatus
This method is mainly here for diagnostic purposes, alongside
TransactionStatus.isNewTransaction()
. For programmatic handling of custom
savepoints, use SavepointManager's operations.
public void createAndHoldSavepoint() throws TransactionException
NestedTransactionNotSupportedException
- if the underlying transaction does not support savepointsTransactionException
public void rollbackToHeldSavepoint() throws TransactionException
TransactionException
public void releaseHeldSavepoint() throws TransactionException
TransactionException
public Object createSavepoint() throws TransactionException
createSavepoint
in interface SavepointManager
SavepointManager.rollbackToSavepoint(java.lang.Object)
or SavepointManager.releaseSavepoint(java.lang.Object)
NestedTransactionNotSupportedException
- if the underlying
transaction does not support savepointsTransactionException
- if the savepoint could not be created,
for example because the transaction is not in an appropriate stategetSavepointManager()
,
SavepointManager
public void rollbackToSavepoint(Object savepoint) throws TransactionException
rollbackToSavepoint
in interface SavepointManager
savepoint
- the savepoint to roll back toNestedTransactionNotSupportedException
TransactionException
- if the rollback failedgetSavepointManager()
,
SavepointManager
public void releaseSavepoint(Object savepoint) throws TransactionException
releaseSavepoint
in interface SavepointManager
savepoint
- the savepoint to releaseNestedTransactionNotSupportedException
- if the underlying
transaction does not support savepointsTransactionException
- if the release failedgetSavepointManager()
,
SavepointManager
protected SavepointManager getSavepointManager()
Default implementation always throws a NestedTransactionNotSupportedException.
NestedTransactionNotSupportedException
- if the underlying transaction does not support savepoints