public interface SavepointManager
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.
TransactionStatus
,
TransactionDefinition.PROPAGATION_NESTED
,
Savepoint
Modifier and Type | Method and Description |
---|---|
Object |
createSavepoint()
Create a new savepoint.
|
void |
releaseSavepoint(Object savepoint)
Explicitly release the given savepoint.
|
void |
rollbackToSavepoint(Object savepoint)
Roll back to the given savepoint.
|
Object createSavepoint() throws TransactionException
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.
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 stateConnection.setSavepoint()
void rollbackToSavepoint(Object savepoint) throws TransactionException
savepoint
- the savepoint to roll back toNestedTransactionNotSupportedException
- if the underlying
transaction does not support savepointsTransactionException
- if the rollback failedConnection.rollback(java.sql.Savepoint)
void releaseSavepoint(Object savepoint) throws TransactionException
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.
savepoint
- the savepoint to releaseNestedTransactionNotSupportedException
- if the underlying
transaction does not support savepointsTransactionException
- if the release failedConnection.releaseSavepoint(java.sql.Savepoint)