public interface

SavepointManager

org.springframework.transaction.SavepointManager
Known Indirect Subclasses

Class Overview

Interface that specifies an API to programmatically manage transaction savepoints in a generic fashion. Extended by TransactionStatus to expose savepoint management functionality for a specific transaction.

Note that savepoints can only work within an active transaction. Just use this programmatic savepoint handling for advanced needs; else, a subtransaction with PROPAGATION_NESTED is preferable.

This interface is inspired by JDBC 3.0's Savepoint mechanism but is independent from any specific persistence technology.

See Also

Summary

Public Methods
abstract Object createSavepoint()
Create a new savepoint.
abstract void releaseSavepoint(Object savepoint)
Explicitly release the given savepoint.
abstract void rollbackToSavepoint(Object savepoint)
Roll back to the given savepoint.

Public Methods

public abstract Object createSavepoint ()

Create a new savepoint. You can roll back to a specific savepoint via rollbackToSavepoint, and explicitly release a savepoint that you don't need anymore via releaseSavepoint.

Note that most transaction managers will automatically release savepoints at transaction completion.

Returns
  • a savepoint object, to be passed into rollbackToSavepoint or releaseSavepoint
Throws
NestedTransactionNotSupportedException if the underlying transaction does not support savepoints
TransactionException if the savepoint could not be created, for example because the transaction is not in an appropriate state
See Also

public abstract void releaseSavepoint (Object savepoint)

Explicitly release the given savepoint.

Note that most transaction managers will automatically release savepoints at transaction completion.

Implementations should fail as silently as possible if proper resource cleanup will still happen at transaction completion.

Parameters
savepoint the savepoint to release
Throws
NestedTransactionNotSupportedException if the underlying transaction does not support savepoints
TransactionException if the release failed

public abstract void rollbackToSavepoint (Object savepoint)

Roll back to the given savepoint. The savepoint will be automatically released afterwards.

Parameters
savepoint the savepoint to roll back to
Throws
NestedTransactionNotSupportedException if the underlying transaction does not support savepoints
TransactionException if the rollback failed