Top Description Methods
org.springframework.transaction

public Interface SavepointManager

Known Direct Subinterfaces
org.springframework.transaction.TransactionStatus

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's Savepoint mechanism but is independent of any specific persistence technology.

Author
Juergen Hoeller
Since
1.1
See Also
TransactionStatus, TransactionDefinition#PROPAGATION_NESTED, java.sql.Savepoint

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

a savepoint object, to be passed into rollbackToSavepoint or releaseSavepoint
createSavepoint
()

Create a new savepoint.

public void
releaseSavepoint(Object
the savepoint to release
savepoint
)

Explicitly release the given savepoint.

public void
rollbackToSavepoint(Object
the savepoint to roll back to
savepoint
)

Roll back to the given savepoint.

Method Detail

createSavepointback to summary
public Object createSavepoint() throws TransactionException

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:Object

a savepoint object, to be passed into rollbackToSavepoint or releaseSavepoint

Exceptions
TransactionException:
if the savepoint could not be created, for example because the transaction is not in an appropriate state
NestedTransactionNotSupportedException:
if the underlying transaction does not support savepoints
See Also
java.sql.Connection#setSavepoint
releaseSavepointback to summary
public void releaseSavepoint(Object savepoint) throws TransactionException

Explicitly release the given savepoint.

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

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

Parameters
savepoint:Object

the savepoint to release

Exceptions
TransactionException:
if the release failed
NestedTransactionNotSupportedException:
if the underlying transaction does not support savepoints
See Also
java.sql.Connection#releaseSavepoint
rollbackToSavepointback to summary
public void rollbackToSavepoint(Object savepoint) throws TransactionException

Roll back to the given savepoint.

The savepoint will not be automatically released afterwards. You may explicitly call releaseSavepoint(Object) or rely on automatic release on transaction completion.

Parameters
savepoint:Object

the savepoint to roll back to

Exceptions
TransactionException:
if the rollback failed
NestedTransactionNotSupportedException:
if the underlying transaction does not support savepoints
See Also
java.sql.Connection#rollback(java.sql.Savepoint)