Transaction propagations in Spring

Defaults to Propagation.REQUIRED

TransactionDefinition.ISOLATION_DEFAULT – Use the default isolation level of the underlying datastore.
TransactionDefinition.ISOLATION_READ_COMMITTED – Indicates that dirty reads are prevented; non-repeatable reads and phantom reads can occur.
TransactionDefinition.ISOLATION_READ_UNCOMMITTED – Indicates that dirty reads, non-repeatable reads and phantom reads can occur.
TransactionDefinition.ISOLATION_REPEATABLE_READ – Indicates that dirty reads and non-repeatable reads are prevented; phantom reads can occur.
TransactionDefinition.ISOLATION_SERIALIZABLE – Indicates that dirty reads, non-repeatable reads and phantom reads are prevented.

TransactionDefinition.PROPAGATION_MANDATORY – Support a current transaction; throw an exception if no current transaction exists.
TransactionDefinition.PROPAGATION_NESTED – Execute within a nested transaction if a current transaction exists, behave like PROPAGATION_REQUIRED else.
TransactionDefinition.PROPAGATION_NEVER – Do not support a current transaction; throw an exception if a current transaction exists.
TransactionDefinition.PROPAGATION_NOT_SUPPORTED – Do not support a current transaction; rather always execute non-transactionally.
TransactionDefinition.PROPAGATION_REQUIRED – Support a current transaction; create a new one if none exists.
TransactionDefinition.PROPAGATION_REQUIRES_NEW – Create a new transaction, suspending the current transaction if one exists.
TransactionDefinition.PROPAGATION_SUPPORTS – Support a current transaction; execute non-transactionally if none exists.

TransactionDefinition.TIMEOUT_DEFAULT – Use the default timeout of the underlying transaction system, or none if timeouts are not supported.

@Transactional (rollbackFor=Exception.class)
@Transactional (noRollbackFor=IllegalStateException.class)

Leave a comment

Your email address will not be published. Required fields are marked *