Spring事务传播
2015-10-10 00:00
411 查看
摘要: Spring事务传播
事务传播在
This is typically the default setting of a transaction definition, and typically defines a transaction synchronization scope.
支持当前事务。如果当前没有事务则创建一个新的事务。
这是事务定义的默认设置,并且定义了一个典型的事务同步域。
NOTE: For transaction managers with transaction synchronization, PROPAGATION_SUPPORTS is slightly different from no transaction at all, as it defines a transaction scope that synchronization might apply to. As a consequence, the same resources (a JDBC Connection, a Hibernate Session, etc) will be shared for the entire specified scope. Note that the exact behavior depends on the actual synchronization configuration of the transaction manager!
In general, use PROPAGATION_SUPPORTS with care! In particular, do not rely on PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW within a PROPAGATION_SUPPORTS scope (which may lead to synchronization conflicts at runtime). If such nesting is unavoidable, make sure to configure your transaction manager appropriately (typically switching to "synchronization on actual transaction").
支持当前事务。如果当前没有的话就以非事务方式执行。
Note that transaction synchronization within a PROPAGATION_MANDATORY scope will always be driven by the surrounding transaction.
支持当前事务,如果当前不存在事务,就抛异常。
NOTE: Actual transaction suspension will not work out-of-the-box on all transaction managers. This in particular applies to
A PROPAGATION_REQUIRES_NEW scope always defines its own transaction synchronizations. Existing synchronizations will be suspended and resumed appropriately.
创建一个新事务。如果当前有事务就暂停它,然后创建一个新事务。
NOTE: Actual transaction suspension will not work out-of-the-box on all transaction managers. This in particular applies to org.springframework.transaction.jta.JtaTransactionManager, which requires the javax.transaction.TransactionManager to be made available it to it (which is server-specific in standard J2EE).
Note that transaction synchronization is not available within a PROPAGATION_NOT_SUPPORTED scope. Existing synchronizations will be suspended and resumed appropriately.
不支持当前事务,而总是以非事务方式执行。
Note that transaction synchronization is not available within a PROPAGATION_NEVER scope.
不支持当前事务,如果当前有事务,就抛异常。
NOTE: Actual creation of a nested transaction will only work on specific transaction managers. Out of the box, this only applies to the JDBC
如果当前存在事务,就在一个嵌套的事务中执行。类似于PROPAGATION_REQUIRED。
事务传播在
org.springframework.transaction.TransactionDefinition中定义
PROPAGATION_REQUIRED
Support a current transaction; create a new one if none exists. Analogous to the EJB transaction attribute of the same name.This is typically the default setting of a transaction definition, and typically defines a transaction synchronization scope.
支持当前事务。如果当前没有事务则创建一个新的事务。
这是事务定义的默认设置,并且定义了一个典型的事务同步域。
PROPAGATION_SUPPORTS
Support a current transaction; execute non-transactionally if none exists. Analogous to the EJB transaction attribute of the same name.NOTE: For transaction managers with transaction synchronization, PROPAGATION_SUPPORTS is slightly different from no transaction at all, as it defines a transaction scope that synchronization might apply to. As a consequence, the same resources (a JDBC Connection, a Hibernate Session, etc) will be shared for the entire specified scope. Note that the exact behavior depends on the actual synchronization configuration of the transaction manager!
In general, use PROPAGATION_SUPPORTS with care! In particular, do not rely on PROPAGATION_REQUIRED or PROPAGATION_REQUIRES_NEW within a PROPAGATION_SUPPORTS scope (which may lead to synchronization conflicts at runtime). If such nesting is unavoidable, make sure to configure your transaction manager appropriately (typically switching to "synchronization on actual transaction").
支持当前事务。如果当前没有的话就以非事务方式执行。
PROPAGATION_MANDATORY
Support a current transaction; throw an exception if no current transaction exists. Analogous to the EJB transaction attribute of the same name.Note that transaction synchronization within a PROPAGATION_MANDATORY scope will always be driven by the surrounding transaction.
支持当前事务,如果当前不存在事务,就抛异常。
PROPAGATION_REQUIRES_NEW
Create a new transaction, suspending the current transaction if one exists. Analogous to the EJB transaction attribute of the same name.NOTE: Actual transaction suspension will not work out-of-the-box on all transaction managers. This in particular applies to
org.springframework.transaction.jta.JtaTransactionManager, which requires the javax.transaction.TransactionManager to be made available it to it (which is server-specific in standard J2EE).
A PROPAGATION_REQUIRES_NEW scope always defines its own transaction synchronizations. Existing synchronizations will be suspended and resumed appropriately.
创建一个新事务。如果当前有事务就暂停它,然后创建一个新事务。
PROPAGATION_NOT_SUPPORTED
Do not support a current transaction; rather always execute non-transactionally. Analogous to the EJB transaction attribute of the same name.NOTE: Actual transaction suspension will not work out-of-the-box on all transaction managers. This in particular applies to org.springframework.transaction.jta.JtaTransactionManager, which requires the javax.transaction.TransactionManager to be made available it to it (which is server-specific in standard J2EE).
Note that transaction synchronization is not available within a PROPAGATION_NOT_SUPPORTED scope. Existing synchronizations will be suspended and resumed appropriately.
不支持当前事务,而总是以非事务方式执行。
PROPAGATION_NEVER
Do not support a current transaction; throw an exception if a current transaction exists. Analogous to the EJB transaction attribute of the same name.Note that transaction synchronization is not available within a PROPAGATION_NEVER scope.
不支持当前事务,如果当前有事务,就抛异常。
PROPAGATION_NESTED
Execute within a nested transaction if a current transaction exists, behave like PROPAGATION_REQUIRED else. There is no analogous feature in EJB.NOTE: Actual creation of a nested transaction will only work on specific transaction managers. Out of the box, this only applies to the JDBC
org.springframework.jdbc.datasource.DataSourceTransactionManagerwhen working on a JDBC 3.0 driver. Some JTA providers might support nested transactions as well.
如果当前存在事务,就在一个嵌套的事务中执行。类似于PROPAGATION_REQUIRED。
相关文章推荐
- 一个jar包里的网站
- 一个jar包里的网站之文件上传
- 一个jar包里的网站之返回对媒体类型
- SQL Server误区30日谈 第1天 正在运行的事务在服务器故障转移后继续执行
- 浅析SQL Server中包含事务的存储过程
- Mysql中的事务是什么如何使用
- MySql的事务使用与示例详解
- C#分布式事务的超时处理实例分析
- C#中的事务用法实例分析
- SQL Server的事务操作隔离模式介绍
- oracle 合并查询 事务 sql函数小知识学习
- spring+html5实现安全传输随机数字密码键盘
- Spring中属性注入详解
- sql不常用函数总结以及事务,增加,删除触发器
- struts2 spring整合fieldError问题
- mysql的XA事务恢复过程详解
- 在Mysql存储过程中使用事务实例
- mysql存储过程事务管理简析
- php+mysql事务rollback&commit示例
- spring的jdbctemplate的crud的基类dao