Interface SavepointManager
- All Known Subinterfaces:
TransactionStatus
- All Known Implementing Classes:
AbstractTransactionStatus
,DefaultTransactionStatus
,JdbcTransactionObjectSupport
,SimpleTransactionStatus
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 of any specific persistence technology.
- Since:
- 1.1
- Author:
- Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionCreate a new savepoint.void
releaseSavepoint
(Object savepoint) Explicitly release the given savepoint.void
rollbackToSavepoint
(Object savepoint) Roll back to the given savepoint.
-
Method Details
-
createSavepoint
Create a new savepoint. You can roll back to a specific savepoint viarollbackToSavepoint
, and explicitly release a savepoint that you don't need anymore viareleaseSavepoint
.Note that most transaction managers will automatically release savepoints at transaction completion.
- Returns:
- a savepoint object, to be passed into
rollbackToSavepoint(java.lang.Object)
orreleaseSavepoint(java.lang.Object)
- Throws:
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 state- See Also:
-
rollbackToSavepoint
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
- the savepoint to roll back to- Throws:
NestedTransactionNotSupportedException
- if the underlying transaction does not support savepointsTransactionException
- if the rollback failed- See Also:
-
releaseSavepoint
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
- the savepoint to release- Throws:
NestedTransactionNotSupportedException
- if the underlying transaction does not support savepointsTransactionException
- if the release failed- See Also:
-