网上虽然有很多 但是还是建议别死记硬背 先看看源码
public enum Propagation {
/**
* Support a current transaction, create a new one if none exists.
* 如果存在一个事务,则支持当前事务。如果没有事务则创建新的事务
* Analogous to EJB transaction attribute of the same name.
* 类似于同名的EJB事务属性
* <p>This is the default setting of a transaction annotation.
* 这是事务注释的默认设置
*/
REQUIRED(TransactionDefinition.PROPAGATION_REQUIRED),
/**
* Support a current transaction, execute non-transactionally if none exists.
* 支持当前事务,如果没有则以非事务方式运行
* Analogous to EJB transaction attribute of the same name.
* <p>Note: For transaction managers with transaction synchronization,
* 用于具有事务同步的事务管理器
* {@code SUPPORTS} is slightly different from no transaction at all,
* 和完全无事务不同
* as it defines a transaction scope that synchronization will apply for.
* 因为它定义了同步将应用的事务范围
* As a consequence, the same resources (JDBC Connection, Hibernate Session, etc)
* will be shared for the entire specified scope. Note that this depends on
* 因此,相同的资源将在整个指定范围内共享
* the actual synchronization configuration of the transaction manager.
* 请注意,这取决于事务管理器的实际同步配置。
* @see org.springframework.transaction.support.AbstractPlatformTransactionManager#setTransactionSynchronization
*/
SUPPORTS(TransactionDefinition.PROPAGATION_SUPPORTS),
/**
* Support a current transaction, throw an exception if none exists.
* 支持当前事务,如果当前上下文不存在事务 则抛异常
* Analogous to EJB transaction attribute of the same name.
*/
MANDATORY(TransactionDefinition.PROPAGATION_MANDATORY),
/**
* Create a new transaction, and suspend the current transaction if one exists.
* 总是创建新的事务,如果当前上下文存在事务则挂起该事务
* Analogous to the EJB transaction attribute of the same name.
* <p><b>NOTE:</b> Actual transaction suspension will not work out-of-the-box
* on all transaction managers. This in particular applies to
* 实际的事务挂起并不会在所有事务管理器上开箱即用
* {@link org.springframework.transaction.jta.JtaTransactionManager},
* which requires the {@code javax.transaction.TransactionManager} to be
* made available to it (which is server-specific in standard Java EE).
* 适用于JtaTransactionManager 要求TransactionManager提供给他
* @see org.springframework.transaction.jta.JtaTransactionManager#setTransactionManager
*/
REQUIRES_NEW(TransactionDefinition.PROPAGATION_REQUIRES_NEW),
/**
* Execute non-transactionally, suspend the current transaction if one exists.
* 以非事务方式运行,如果当前存在事务则挂起该事务
* Analogous to EJB transaction attribute of the same name.
* <p><b>NOTE:</b> Actual transaction suspension will not work out-of-the-box
* on all transaction managers. This in particular applies to
* 实际的事务挂起并不会在所有事务管理器上开箱即用
* {@link org.springframework.transaction.jta.JtaTransactionManager},
* which requires the {@code javax.transaction.TransactionManager} to be
* made available to it (which is server-specific in standard Java EE).
* 适用于JtaTransactionManager 要求TransactionManager提供给他
* @see org.springframework.transaction.jta.JtaTransactionManager#setTransactionManager
*/
NOT_SUPPORTED(TransactionDefinition.PROPAGATION_NOT_SUPPORTED),
/**
* Execute non-transactionally, throw an exception if a transaction exists.
* 非事务执行,如果当前上下文存在事务则抛出异常
* Analogous to EJB transaction attribute of the same name.
*/
NEVER(TransactionDefinition.PROPAGATION_NEVER),
/**
* Execute within a nested transaction if a current transaction exists,
* behave like {@code REQUIRED} otherwise. There is no analogous feature in EJB.
* 如果一个活动的事务存在,则运行在一个嵌套的事务中. 如果没有活动事务,
* 则按TransactionDefinition.PROPAGATION_REQUIRED 属性执行
* <p>Note: Actual creation of a nested transaction will only work on specific
* transaction managers. Out of the box, this only applies to the JDBC
* DataSourceTransactionManager. Some JTA providers might support nested
* transactions as well.
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager
*/
NESTED(TransactionDefinition.PROPAGATION_NESTED);
private final int value;
Propagation(int value) {
this.value = value;
}
public int value() {
return this.value;
}
}
除了最后一个是spring自创的 其他的和mysql引擎的一致,也和EJB一致
总结如下