TransactionRollback
Rollback the current transaction and discard all unpersisted queries.
Only the changes made since the last transactionSetSavepoint()
or transactionCommit()
call will be discarded.
If no transaction is found in the current context, this method will throw an exception.
Method Signature
Arguments
Argument | Type | Required | Description | Default |
---|---|---|---|---|
|
|
| String name of the savepoint to rollback to. If not provided, the entire transaction will be rolled back. |
Examples
Using TransactionRollback with TransactionCommit
This simple example shows two JDBC queries executed inside a transaction. The first query, an INSERT, is committed to the database while the second is rolled back.
Note that the rollback cannot affect the INSERT statement, since it has already been committed ("persisted") to the database.
Using TransactionRollback with TransactionSetSavepoint
Many times, you may wish to roll back only a portion of a transaction. This is possible by setting a "savepoint" upon the transaction:
Multiple savepoints can be set or referenced.
Related
Last updated