public abstract class

AbstractTransactionStatus

extends Object
implements TransactionStatus
java.lang.Object
   ↳ org.springframework.transaction.support.AbstractTransactionStatus
Known Direct Subclasses

Class Overview

Abstract base implementation of the 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.

Summary

Public Constructors
AbstractTransactionStatus()
Public Methods
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.
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.
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 Methods
Object getSavepoint()
Get the savepoint for this transaction, if any.
SavepointManager getSavepointManager()
Return a SavepointManager for the underlying transaction, if possible.
void setSavepoint(Object savepoint)
Set a savepoint for this transaction.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.transaction.SavepointManager
From interface org.springframework.transaction.TransactionStatus

Public Constructors

public AbstractTransactionStatus ()

Public Methods

public void createAndHoldSavepoint ()

Create a savepoint and hold it for the transaction.

Throws
NestedTransactionNotSupportedException if the underlying transaction does not support savepoints
TransactionException

public Object createSavepoint ()

This implementation delegates to a SavepointManager for the underlying transaction, if possible.

Returns
  • a savepoint object, to be passed into rollbackToSavepoint or releaseSavepoint

public void flush ()

This implementations is empty, considering flush as a no-op.

public boolean hasSavepoint ()

Return whether this transaction internally carries a savepoint, that is, has been created as nested transaction based on a savepoint.

This method is mainly here for diagnostic purposes, alongside isNewTransaction(). For programmatic handling of custom savepoints, use SavepointManager's operations.

public boolean isCompleted ()

Return whether this transaction is completed, that is, whether it has already been committed or rolled back.

public boolean isGlobalRollbackOnly ()

Template method for determining the global rollback-only flag of the underlying transaction, if any.

This implementation always returns false.

public boolean isLocalRollbackOnly ()

Determine the rollback-only flag via checking this TransactionStatus.

Will only return "true" if the application called setRollbackOnly on this TransactionStatus object.

public 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.

public void releaseHeldSavepoint ()

Release the savepoint that is held for the transaction.

public void releaseSavepoint (Object savepoint)

This implementation delegates to a SavepointManager for the underlying transaction, if possible.

Parameters
savepoint the savepoint to release

public void rollbackToHeldSavepoint ()

Roll back to the savepoint that is held for the transaction.

public void rollbackToSavepoint (Object savepoint)

This implementation delegates to a SavepointManager for the underlying transaction, if possible.

Parameters
savepoint the savepoint to roll back to
Throws
org.springframework.transaction.NestedTransactionNotSupportedException
TransactionException

public void setCompleted ()

Mark this transaction as completed, that is, committed or rolled back.

public void setRollbackOnly ()

Set the transaction rollback-only. This instructs the transaction manager that the only possible outcome of the transaction may be a rollback, as alternative to throwing an exception which would in turn trigger a rollback.

This is mainly intended for transactions managed by TransactionTemplate or TransactionInterceptor, where the actual commit/rollback decision is made by the container.

Protected Methods

protected Object getSavepoint ()

Get the savepoint for this transaction, if any.

protected SavepointManager getSavepointManager ()

Return a SavepointManager for the underlying transaction, if possible.

Default implementation always throws a NestedTransactionNotSupportedException.

Throws
NestedTransactionNotSupportedException if the underlying transaction does not support savepoints

protected void setSavepoint (Object savepoint)

Set a savepoint for this transaction. Useful for PROPAGATION_NESTED.