- Method must run within transaction. If there is no currently active transaction going on an exception is thrown.
- Method must run within transaction. If there is already started transaction method will run within that transaction, otherwise new transaction will be started.
- Method must run within it’s own transaction. Spring will always create a new transaction for this method. If there is already started transaction going on, it will be suspended for duration of this method.
- Method will be run within nested transaction. If no transaction is present new transaction will be started, otherwise a nested transaction will be started.
- Method should not run within transaction. If there is active transaction going on it will be suspended for duration of this method call.
- Method should not run within transaction. An exception will be thrown if method is called and there is active transaction going on.
|Isolation Level||Dirty Reads||Nonrepeatable reads||Phantom reads|
DEFAULT isolation level uses transaction isolation level provided
by underlying implementation.
- Dirty Reads
- Transaction may read data written but not yet committed by other transactions.
- Performing the same query twice may return different data. Usually this happens because some other transaction updated data and was successfully committed after first but before second query.
- Phantom reads
- When we query for set of rows twice second query may return rows not present in result returned by first query. Usually this happens because some other transaction inserted rows to queried table and was successfully committed between our queries.
By default transaction are rolled back only
on uncaught runtime exceptions.
noRollbackFor properties allows us to
set additional exceptions types for which transaction should
or should not rolled back.
readOnly=true when transaction doesn’t write back
to database. This will allow underlying implementation to
possibly optimize data access.
This settings make sense only on methods that start new
transaction (with propagation
Transaction timeout in seconds.