public abstract class AbstractTransactionStatus extends java.lang.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.
|
java.lang.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 java.lang.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(java.lang.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(java.lang.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(java.lang.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 java.io.Flushable
flush
in interface TransactionStatus
public void setCompleted()
public boolean isCompleted()
TransactionStatus
protected void setSavepoint(@Nullable java.lang.Object savepoint)
TransactionDefinition.PROPAGATION_NESTED
@Nullable protected java.lang.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 java.lang.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.createSavepoint()
public void rollbackToSavepoint(java.lang.Object savepoint) throws TransactionException
rollbackToSavepoint
in interface SavepointManager
savepoint
- the savepoint to roll back toNestedTransactionNotSupportedException
- if the underlying
transaction does not support savepointsTransactionException
- if the rollback failedgetSavepointManager()
,
SavepointManager.rollbackToSavepoint(Object)
public void releaseSavepoint(java.lang.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.releaseSavepoint(Object)
protected SavepointManager getSavepointManager()
Default implementation always throws a NestedTransactionNotSupportedException.
NestedTransactionNotSupportedException
- if the underlying transaction does not support savepoints