Top Description Fields Constructors Methods
org.springframework.transaction.support

public Class SimpleTransactionStatus

extends AbstractTransactionStatus
Class Inheritance

A simple org.springframework.transaction.TransactionStatus implementation. Derives from AbstractTransactionStatus and adds an explicit "newTransaction" flag.

This class is not used by any of Spring's pre-built org.springframework.transaction.PlatformTransactionManager implementations. It is mainly provided as a start for custom transaction manager implementations and as a static mock for testing transactional code (either as part of a mock PlatformTransactionManager or as argument passed into a TransactionCallback to be tested).

Author
Juergen Hoeller
Since
1.2.3
See Also
TransactionCallback#doInTransaction

Field Summary

Modifier and TypeField and Description
private final boolean

Constructor Summary

AccessConstructor and Description
public
SimpleTransactionStatus()

Create a new SimpleTransactionStatus instance, indicating a new transaction.

public
SimpleTransactionStatus(boolean
whether to indicate a new transaction
newTransaction
)

Create a new SimpleTransactionStatus instance.

Method Summary

Modifier and TypeMethod and Description
public boolean
isNewTransaction()

Overrides default org.springframework.transaction.TransactionExecution.isNewTransaction.

Return whether the transaction manager considers the present transaction as new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.

Inherited from org.springframework.transaction.support.AbstractTransactionStatus:
createAndHoldSavepointcreateSavepointgetSavepointgetSavepointManagerhasSavepointisCompletedisGlobalRollbackOnlyisLocalRollbackOnlyisRollbackOnlyreleaseHeldSavepointreleaseSavepointrollbackToHeldSavepointrollbackToSavepointsetCompletedsetRollbackOnlysetSavepoint

Field Detail

newTransactionback to summary
private final boolean newTransaction

Constructor Detail

SimpleTransactionStatusback to summary
public SimpleTransactionStatus()

Create a new SimpleTransactionStatus instance, indicating a new transaction.

SimpleTransactionStatusback to summary
public SimpleTransactionStatus(boolean newTransaction)

Create a new SimpleTransactionStatus instance.

Parameters
newTransaction:boolean

whether to indicate a new transaction

Method Detail

isNewTransactionback to summary
public boolean isNewTransaction()

Overrides default org.springframework.transaction.TransactionExecution.isNewTransaction.

Doc from org.springframework.transaction.TransactionExecution.isNewTransaction.

Return whether the transaction manager considers the present transaction as new; otherwise participating in an existing transaction, or potentially not running in an actual transaction in the first place.

This is primarily here for transaction manager state handling. Prefer the use of hasTransaction() for application purposes since this is usually semantically appropriate.

The "new" status can be transaction manager specific, e.g. returning true for an actual nested transaction but potentially false for a savepoint-based nested transaction scope if the savepoint management is explicitly exposed (such as on TransactionStatus). A combined check for any kind of nested execution is provided by isNested().

The default implementation returns true.

Annotations
@Override