spring事务PROPAGATION_REQUIRES_NEW和PROPAGATION_NESTED区别

Spring 的不同事务传播行为 综上所述,PROPAGATION_REQUIRES_NEW事务主要用于需要确保某些操作在独立事务中完成的场景。通过合理使用该传播行为,可以确保这些操作的原子性和独立性,从而提高应用的健壮性和可靠性。综上所述,PROPAGATION_NESTED事务主要用于复杂业务操作、保存点回滚和事务隔离等场景。通过合理使用该传播行为,可以确保业务操作的原子性和独立性,从而提高应用的健壮性和可靠性。PROPAGATION_NESTED是Spring事务管理中的一种传播行为,它允许在当前事务中嵌套一个新的事务。 阅读详情
解惑 spring 嵌套事务 

   在所有使用 spring 的应用中, 声明式事务管理可能是使用率最高的功能了, 但是, 从我观察到的情况看, 
绝大多数人并不能深刻理解事务声明中不同事务传播属性配置的的含义, 让我们来看一下 TransactionDefinition 接口中的定义 

Java代码  收藏代码
[java]  view plain copy
  1. /**  
  2.      * Support a current transaction, create a new one if none exists.  
  3.      * Analogous to EJB transaction attribute of the same name.  
  4.      * <p>This is typically the default setting of a transaction definition.  
  5.      */    
  6.     int PROPAGATION_REQUIRED = 0;    
  7.     
  8.     /**  
  9.      * Support a current transaction, execute non-transactionally if none exists.  
  10.      * Analogous to EJB transaction attribute of the same name.  
  11.      * <p>Note: For transaction managers with transaction synchronization,  
  12.      * PROPAGATION_SUPPORTS is slightly different from no transaction at all,  
  13.      * as it defines a transaction scopp that synchronization will apply for.  
  14.      * As a consequence, the same resources (JDBC Connection, Hibernate Session, etc)  
  15.      * will be shared for the entire specified scope. Note that this depends on  
  16.      * the actual synchronization configuration of the transaction manager.  
  17.      * @see org.springframework.transaction.support.AbstractPlatformTransactionManager#setTransactionSynchronization  
  18.      */    
  19.     int PROPAGATION_SUPPORTS = 1;    
  20.     
  21.     /**  
  22.      * Support a current transaction, throw an exception if none exists.  
  23.      * Analogous to EJB transaction attribute of the same name.  
  24.      */    
  25.     int PROPAGATION_MANDATORY = 2;    
  26.     
  27.     /**  
  28.      * Create a new transaction, suspend the current transaction if one exists.  
  29.      * Analogous to EJB transaction attribute of the same name.  
  30.      * <p>Note: Actual transaction suspension will not work on out-of-the-box  
  31.      * on all transaction managers. This in particular applies to JtaTransactionManager,  
  32.      * which requires the <code>javax.transaction.TransactionManager</code> to be  
  33.      * made available it to it (which is server-specific in standard J2EE).  
  34.      * @see org.springframework.transaction.jta.JtaTransactionManager#setTransactionManager  
  35.      */    
  36.     int PROPAGATION_REQUIRES_NEW = 3;    
  37.     
  38.     /**  
  39.      * Execute non-transactionally, suspend the current transaction if one exists.  
  40.      * Analogous to EJB transaction attribute of the same name.  
  41.      * <p>Note: Actual transaction suspension will not work on out-of-the-box  
  42.      * on all transaction managers. This in particular applies to JtaTransactionManager,  
  43.      * which requires the <code>javax.transaction.TransactionManager</code> to be  
  44.      * made available it to it (which is server-specific in standard J2EE).  
  45.      * @see org.springframework.transaction.jta.JtaTransactionManager#setTransactionManager  
  46.      */    
  47.     int PROPAGATION_NOT_SUPPORTED = 4;    
  48.     
  49.     /**  
  50.      * Execute non-transactionally, throw an exception if a transaction exists.  
  51.      * Analogous to EJB transaction attribute of the same name.  
  52.      */    
  53.     int PROPAGATION_NEVER = 5;    
  54.     
  55.     /**  
  56.      * Execute within a nested transaction if a current transaction exists,  
  57.      * behave like PROPAGATION_REQUIRED else. There is no analogous feature in EJB.  
  58.      * <p>Note: Actual creation of a nested transaction will only work on specific  
  59.      * transaction managers. Out of the box, this only applies to the JDBC  
  60.      * DataSourceTransactionManager when working on a JDBC 3.0 driver.  
  61.      * Some JTA providers might support nested transactions as well.  
  62.      * @see org.springframework.jdbc.datasource.DataSourceTransactionManager  
  63.      */    
  64.     int PROPAGATION_NESTED = 6;    


我们可以看到, 在 spring 中一共定义了六种事务传播属性, 如果你觉得看起来不够直观, 那么我来转贴一个满大街都有的翻译 

引用

PROPAGATION_REQUIRED -- 支持当前事务,如果当前没有事务,就新建一个事务。这是最常见的选择。 
PROPAGATION_SUPPORTS -- 支持当前事务,如果当前没有事务,就以非事务方式执行。 
PROPAGATION_MANDATORY -- 支持当前事务,如果当前没有事务,就抛出异常。 
PROPAGATION_REQUIRES_NEW -- 新建事务,如果当前存在事务,把当前事务挂起。 
PROPAGATION_NOT_SUPPORTED -- 以非事务方式执行操作,如果当前存在事务,就把当前事务挂起。 
PROPAGATION_NEVER -- 以非事务方式执行,如果当前存在事务,则抛出异常。 
PROPAGATION_NESTED -- 如果当前存在事务,则在嵌套事务内执行。如果当前没有事务,则进行与PROPAGATION_REQUIRED类似的操作。 
前六个策略类似于EJB CMT,第七个(PROPAGATION_NESTED)是Spring所提供的一个特殊变量。 
它要求事务管理器或者使用JDBC 3.0 Savepoint API提供嵌套事务行为(如Spring的DataSourceTransactionManager) 

在我所见过的误解中, 最常见的是下面这种: 

引用
假如有两个业务接口 ServiceA 和 ServiceB, 其中 ServiceA 中有一个方法实现如下 

[java]  view plain copy
  1. /**  
  2. * 事务属性配置为 PROPAGATION_REQUIRED  
  3. */   
  4. void methodA() {   
  5. // 调用 ServiceB 的方法   
  6. ServiceB.methodB();   
  7. }   


那么如果 ServiceB 的 methodB  如果配置了事务, 就必须配置为 PROPAGATION_NESTED 

这种想法可能害了不少人, 认为 Service 之间应该避免互相调用, 其实根本不用担心这点,PROPAGATION_REQUIRED 已经说得很明白, 
如果当前线程中已经存在事务, 方法调用会加入此事务, 果当前没有事务,就新建一个事务, 所以 ServiceB#methodB() 的事务只要遵循最普通的规则配置为 PROPAGATION_REQUIRED 即可, 如果 ServiceB#methodB (我们称之为内部事务, 为下文打下基础) 抛了异常, 那么 ServiceA#methodA(我们称之为外部事务) 如果没有特殊配置此异常时事务提交 (即 +MyCheckedException的用法), 那么整个事务是一定要 rollback 的, 什么 Service 只能调 Dao 之类的言论纯属无稽之谈, spring 只负责配置了事务属性方法的拦截, 它怎么知道你这个方法是在 Service 还是 Dao 里 ? 

     说了这么半天, 那到底什么是真正的事务嵌套呢, 解释之前我们来看一下  Juergen Hoeller 的原话 

Juergen Hoeller 写道

[plain]  view plain copy
  1. PROPAGATION_REQUIRES_NEW starts a new, independent "inner" transaction for the given scope. This transaction will be committed or rolled back completely independent from the outer transaction, having its own isolation scope, its own set of locks, etc. The outer transaction will get suspended at the beginning of the inner one, and resumed once the inner one has completed.   
  2.   
  3. Such independent inner transactions are for example used for id generation through manual sequences, where the access to the sequence table should happen in its own transactions, to keep the lock there as short as possible. The goal there is to avoid tying the sequence locks to the (potentially much longer running) outer transaction, with the sequence lock not getting released before completion of the outer transaction.   
  4.   
  5. PROPAGATION_NESTED on the other hand starts a "nested" transaction, which is a true subtransaction of the existing one. What will happen is that a savepoint will be taken at the start of the nested transaction. íf the nested transaction fails, we will roll back to that savepoint. The nested transaction is part of of the outer transaction, so it will only be committed at the end of of the outer transaction.   
  6.   
  7. Nested transactions essentially allow to try some execution subpaths as subtransactions: rolling back to the state at the beginning of the failed subpath, continuing with another subpath or with the main execution path there - all within one isolated transaction, and not losing any previous work done within the outer transaction.   
  8.   
  9. For example, consider parsing a very large input file consisting of account transfer blocks: The entire file should essentially be parsed within one transaction, with one single commit at the end. But if a block fails, its transfers need to be rolled back, writing a failure marker somewhere. You could either start over the entire transaction every time a block fails, remembering which blocks to skip - or you mark each block as a nested transaction, only rolling back that specific set of operations, keeping the previous work of the outer transaction. The latter is of course much more efficient, in particular when a block at the end of the file fails.   


Juergen Hoeller 写道
[plain]  view plain copy
  1. Rolling back the entire transaction is the choice of the demarcation code/config that started the outer transaction.   
  2.   
  3. So if an inner transaction throws an exception and is supposed to be rolled back (according to the rollback rules), the transaction will get rolled back to the savepoint taken at the start of the inner transaction. The immediate calling code can then decide to catch the exception and proceed down some other path within the outer transaction.   
  4.   
  5. If the code that called the inner transaction lets the exception propagate up the call chain, the exception will eventually reach the demarcation code of the outer transaction. At that point, the rollback rules of the outer transaction decide whether to trigger a rollback. That would be a rollback of the entire outer transaction then.   
  6.   
  7. So essentially, it depends on your exception handling. If you catch the exception thrown by the inner transaction, you can proceed down some other path within the outer transaction. If you let the exception propagate up the call chain, it's eventually gonna cause a rollback of the entire outer transaction.   

    也就是说, 最容易弄混淆的其实是 PROPAGATION_REQUIRES_NEW 和 PROPAGATION_NESTED, 那么这两种方式又有何区别呢? 我简单的翻译一下 Juergen Hoeller 的话 : 
    
    PROPAGATION_REQUIRES_NEW 启动一个新的, 不依赖于环境的 "内部" 事务. 这个事务将被完全 commited 或 rolled back 而不依赖于外部事务, 它拥有自己的隔离范围, 自己的锁, 等等. 当内部事务开始执行时, 外部事务将被挂起, 内务事务结束时, 外部事务将继续执行. 

    另一方面, PROPAGATION_NESTED 开始一个 "嵌套的" 事务,  它是已经存在事务的一个真正的子事务. 潜套事务开始执行时,  它将取得一个 savepoint. 如果这个嵌套事务失败, 我们将回滚到此 savepoint. 潜套事务是外部事务的一部分, 只有外部事务结束后它才会被提交. 

    由此可见, PROPAGATION_REQUIRES_NEW 和 PROPAGATION_NESTED 的最大区别在于, PROPAGATION_REQUIRES_NEW 完全是一个新的事务, 而 PROPAGATION_NESTED 则是外部事务的子事务, 如果外部事务 commit, 潜套事务也会被 commit, 这个规则同样适用于 roll back. 

    
    那么外部事务如何利用嵌套事务的 savepoint 特性呢, 我们用代码来说话 
    
Java代码  收藏代码

[java]  view plain copy
  1. ServiceA {    
  2.         
  3.     /**  
  4.      * 事务属性配置为 PROPAGATION_REQUIRED  
  5.      */    
  6.     void methodA() {    
  7.         ServiceB.methodB();    
  8.     }    
  9.     
  10. }    
  11.     
  12. ServiceB {    
  13.         
  14.     /**  
  15.      * 事务属性配置为 PROPAGATION_REQUIRES_NEW  
  16.      */     
  17.     void methodB() {    
  18.     }    
  19.         
  20. }       


这种情况下, 因为 ServiceB#methodB 的事务属性为 PROPAGATION_REQUIRES_NEW, 所以两者不会发生任何关系, ServiceA#methodA 和 ServiceB#methodB 不会因为对方的执行情况而影响事务的结果, 因为它们根本就是两个事务, 在 ServiceB#methodB 执行时 ServiceA#methodA 的事务已经挂起了 (关于事务挂起的内容已经超出了本文的讨论范围, 有时间我会再写一些挂起的文章) . 

那么 PROPAGATION_NESTED 又是怎么回事呢? 继续看代码 

Java代码  收藏代码

[java]  view plain copy
  1. ServiceA {    
  2.         
  3.     /**  
  4.      * 事务属性配置为 PROPAGATION_REQUIRED  
  5.      */    
  6.     void methodA() {    
  7.         ServiceB.methodB();    
  8.     }    
  9.     
  10. }    
  11.     
  12. ServiceB {    
  13.         
  14.     /**  
  15.      * 事务属性配置为 PROPAGATION_NESTED  
  16.      */     
  17.     void methodB() {    
  18.     }          
  19. }   


现在的情况就变得比较复杂了, ServiceB#methodB 的事务属性被配置为 PROPAGATION_NESTED, 此时两者之间又将如何协作呢? 从 Juergen Hoeller 的原话中我们可以找到答案, ServiceB#methodB 如果 rollback, 那么内部事务(即 ServiceB#methodB) 将回滚到它执行前的 SavePoint(注意, 这是本文中第一次提到它, 潜套事务中最核心的概念), 而外部事务(即 ServiceA#methodA) 可以有以下两种处理方式: 

1. 改写 ServiceA 如下 
Java代码 

[java]  view plain copy
  1. ServiceA {    
  2.         
  3.     /**  
  4.      * 事务属性配置为 PROPAGATION_REQUIRED  
  5.      */    
  6.     void methodA() {    
  7.         try {    
  8.             ServiceB.methodB();    
  9.         } catch (SomeException) {    
  10.             // 执行其他业务, 如 ServiceC.methodC();    
  11.         }    
  12.     }    
  13.     
  14. }    


这种方式也是潜套事务最有价值的地方, 它起到了分支执行的效果, 如果 ServiceB.methodB 失败, 那么执行 ServiceC.methodC(), 而 ServiceB.methodB 已经回滚到它执行之前的 SavePoint, 所以不会产生脏数据(相当于此方法从未执行过), 这种特性可以用在某些特殊的业务中, 而 PROPAGATION_REQUIRED 和 PROPAGATION_REQUIRES_NEW 都没有办法做到这一点. (题外话 : 看到这种代码, 似乎似曾相识, 想起了 prototype.js 中的 Try 函数 ) 

2. 代码不做任何修改, 那么如果内部事务(即 ServiceB#methodB) rollback, 那么首先 ServiceB.methodB 回滚到它执行之前的 SavePoint(在任何情况下都会如此), 
   外部事务(即 ServiceA#methodA) 将根据具体的配置决定自己是 commit 还是 rollback (+MyCheckedException). 
      
上面大致讲述了潜套事务的使用场景, 下面我们来看如何在 spring 中使用 PROPAGATION_NESTED, 首先来看 AbstractPlatformTransactionManager 


Java代码  收藏代码

[java]  view plain copy
  1. /**  
  2.  * Create a TransactionStatus for an existing transaction.  
  3.  */    
  4. private TransactionStatus handleExistingTransaction(    
  5.         TransactionDefinition definition, Object transaction, boolean debugEnabled)    
  6.         throws TransactionException {    
  7.     
  8.    ... 省略    
  9.     
  10.     if (definition.getPropagationBehavior() == TransactionDefinition.PROPAGATION_NESTED) {    
  11.         if (!isNestedTransactionAllowed()) {    
  12.             throw new NestedTransactionNotSupportedException(    
  13.                     "Transaction manager does not allow nested transactions by default - " +    
  14.                     "specify 'nestedTransactionAllowed' property with value 'true'");    
  15.         }    
  16.         if (debugEnabled) {    
  17.             logger.debug("Creating nested transaction with name [" + definition.getName() + "]");    
  18.         }    
  19.         if (useSavepointForNestedTransaction()) {    
  20.             // Create savepoint within existing Spring-managed transaction,    
  21.             // through the SavepointManager API implemented by TransactionStatus.    
  22.             // Usually uses JDBC 3.0 savepoints. Never activates Spring synchronization.    
  23.             DefaultTransactionStatus status =    
  24.                     newTransactionStatus(definition, transaction, false, false, debugEnabled, null);    
  25.             status.createAndHoldSavepoint();    
  26.             return status;    
  27.         }    
  28.         else {    
  29.             // Nested transaction through nested begin and commit/rollback calls.    
  30.             // Usually only for JTA: Spring synchronization might get activated here    
  31.             // in case of a pre-existing JTA transaction.    
  32.             doBegin(transaction, definition);    
  33.             boolean newSynchronization = (this.transactionSynchronization != SYNCHRONIZATION_NEVER);    
  34.             return newTransactionStatus(definition, transaction, true, newSynchronization, debugEnabled, null);    
  35.         }    
  36.     }    
  37. }    


一目了然 

1. 我们要设置 transactionManager 的 nestedTransactionAllowed 属性为 true, 注意, 此属性默认为 false!!! 

再看 AbstractTransactionStatus#createAndHoldSavepoint() 方法 

[java]  view plain copy
  1. /**  
  2.  * Create a savepoint and hold it for the transaction.  
  3.  * @throws org.springframework.transaction.NestedTransactionNotSupportedException  
  4.  * if the underlying transaction does not support savepoints  
  5.  */    
  6. public void createAndHoldSavepoint() throws TransactionException {    
  7.     setSavepoint(getSavepointManager().createSavepoint());    
  8. }    


   可以看到 Savepoint 是 SavepointManager.createSavepoint 实现的, 再看 SavepointManager 的层次结构, 发现 
  其 Template 实现是 JdbcTransactionObjectSupport, 常用的 DatasourceTransactionManager, HibernateTransactionManager 
  中的 TransactonObject 都是它的子类 : 
   
  JdbcTransactionObjectSupport 告诉我们必须要满足两个条件才能 createSavepoint : 
  
2. java.sql.Savepoint 必须存在, 即 jdk 版本要 1.4+ 
3. Connection.getMetaData().supportsSavepoints() 必须为 true, 即 jdbc drive 必须支持 JDBC 3.0 



确保以上条件都满足后, 你就可以尝试使用 PROPAGATION_NESTED 了. 


转自:http://www.iteye.com/topic/35907

医学图像处理实战:3D Slicer从安装到病灶分析全流程指南 本文提供了一份详尽的3D Slicer实战指南,涵盖从软件安装、DICOM数据导入到图像增强、病灶分割及三维可视化的全流程。重点演示了如何利用阈值分割、区域生长等核心图像处理技术进行病灶分析,并生成定量报告,是医学影像分析初学者的实用入门教程。 阅读详情

相关推荐

自动驾驶开发者必看:nuscenes数据集23类物体标注全解析(附避坑指南)

本文深入解析nuscenes数据集的23类物体标注系统,为自动驾驶开发者提供全面的标注规范解读和实战避坑指南。涵盖多模态数据组织、类别细分规则、属性系统应用技巧以及标注质量验证方法,帮助开发者高效利用这一标杆数据集提升模型性能。

weixin_29041767的博客 259

Spring的嵌套事务(Propagation.NESTED)到底是个啥

SavePoint是数据库事务中的一个概念, 可以将整个事务切割为不同的小事务, 可以选择将状态回滚到某个小事务发生时的样子。Propagation.NESTED 则是外部事务的子事务, 如果外部事务 commit, 嵌套事务也会被 commit, 这个规则同样适用于rollback.嵌套事务开始执行时, 它将取得一个 savepoint, 如果这个嵌套事务失败, 我们将回滚到此 savepoint,嵌套事务是外部事务的一部分, 只有外部事务结束后它才会被提交.

cainiao1412的博客 5530

TMS320F280039 CMD文件配置避坑指南:从.map文件看懂内存分配与溢出排查

本文详细解析了TMS320F280039芯片的CMD文件配置问题,通过.map文件分析内存分配与溢出排查。文章提供了实用的诊断技巧和解决方案,帮助开发者有效应对段溢出、地址重叠和栈堆冲突等常见问题,优化DSP程序的内存管理。

weixin_29168813的博客 446

【spring】spring 的事务(transaction) 四 嵌套事务PROPAGATION_NESTED

文章目录1. 什么是嵌套事务PROPAGATION_NESTED2. PROPAGATION_NESTED 与PROPAGATION_REQUIRES_NEW的区别2.1 验证PROPAGATION_REQUIRES_NEW内层事务执行完就立即提交2.2 验证PROPAGATION_NESTED 内层事务执行完未立即提交2.3 验证PROPAGATION_NESTED 内层事务回滚 相关文章 spring 的事务(transaction) 一 基础概念介绍 spring 的事务(transaction) 二

m0_45406092的博客 1万+

不只是驱动:拆解AIC8800 WiFi模组在RK Android系统的完整启动链(从DTS到HAL)

本文深入解析了AIC8800 WiFi模组在RK Android系统中的完整启动链,从设备树(DTS)配置到HAL层适配,涵盖驱动移植、固件加载及用户空间服务协同等关键环节。通过详细的技术分析和调试技巧,帮助开发者解决RK平台与AIC8800模组的兼容性问题,优化WiFi子系统性能。

weixin_30439067的博客 492

FPGA人脸识别检测(先获取人脸图像以及灰度二值化)

由于图片有空洞等缺陷,所以后面要进行中值滤波、腐蚀、膨胀等算法处理,然后再对人脸进行框选,最后显示出来。最终的成像应该是下面这样的。(后面有时间再接着做哈哈哈)5、通过modelsim将操作后的图片数据写入gray_img.txt里面后,用matlab将txt转成图片。1、先用matlab将图片转换成txt数据,代码如下。读取图片的方式按照博客咸鱼里的方式来做,如下。2、FPGA读取txt数据。4、FPGA顶层模块及仿真。3、FPGA灰度二值化。

weixin_46312715的博客 2531

SPRING 事务控制

在 SPRING 中一共定义了六种事务传播属性 PROPAGATION_REQUIRED -- 支持当前事务,如果当前没有事务,就新建一个事务。这是最常见的选择。 PROPAGATION_SUPPORTS -- 支持当前事务,如果当前没有事务,就以非事务方式执行。 PROPAGATION_MANDATORY -- 支持当前事务,如果当前没有事务,就抛出异常。 PROPAGAT...

woi123的专栏 541

ESP32 DW1000 UWB 室内定位系统

详细介绍ESP32 DW1000 UWB 室内定位系统的设计演示demo。

DT程序员的博客 1662

spring事务PROPAGATION_NESTED 与PROPAGATION_REQUIRES_NEW

spring事务PROPAGATION_NESTED 与PROPAGATION_REQUIRES_NEW

qq_33271461的博客 1318

STM32实现等精度测频

上一章介绍了利用STM32的TIM的捕获功能实现频率测量的方法,但测量误差受被测信号频率的影响,不适合测量频率变化较大的。本章将介绍等精度测频的方法以及STM32的实现。STM3...

zhang062061的专栏 3457

【SI好文翻译】铜箔表面纹理对损耗的影响:一个有效的模型(三)

真正的导体表面并不是完全平坦的。 有意将铜表面制造成粗糙的,以使它们在高温和压力下粘附到层压叠层中的电介质传播介质上; 剥离测试通常用于确定粘附的质量。 图 8 显示了为本研究制造的六层高轮廓层印刷电路板在四种不同的扫描电子显微镜放大倍数下的表面粗糙度。 照片中可以看到蚀刻的微带线(顶部和底部)、嵌入的玻璃纤维束、树脂阻焊层和一些杂质。

小孟同学的博客 1638

Spring 事务传播机制源码浅析——PROPAGATION_PROPAGATION_NESTED 事务嵌套

举个例子:下面有三条执行语句,先后对 age 字段做了相应的修改,但是有时候我希望保留第一次的修改值,第二、三次修改给我回滚,这个时候就需要使用到保存点 savepoint 了。创建 savepoint 保存点,用来标志回滚到什么位置,回滚操作,只需要 rollback b,这样就只保留了第一次修改,其他两次修改都不会成功,这就是 savepoint 的作用进入源码如下:获取到 Connection 连接对象,调用 JDBC API 创建保存点。

龚小帅的博客 1244

VTK实战完整教程介绍

该专栏以VTK提供的Example为基础,讲解VTK中的相关接口和使用方法。订阅该专栏,带你了解所有VTK的功能,以便VTK更好的解决工作中遇到的问题。一起学习起来吧!

qq_40041064的博客 2512

spring事务PROPAGATION_REQUIRES_NEW和PROPAGATION_NESTED区别(转载)

解惑 spring 嵌套事务     在所有使用 spring 的应用中, 声明式事务管理可能是使用率最高的功能了, 但是, 从我观察到的情况看,  绝大多数人并不能深刻理解事务声明中不同事务传播属性配置的的含义, 让我们来看一下 TransactionDefinition 接口中的定义  Java代码  收藏代码 [java] view plain copy

凌夏大叔的博客 799

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

关于PROPAGATION_NESTED的理解

查了一些资料,感觉并不能很清晰地表达出两者的差异。所以打算自己总结一下。 先来看一下Spring中对于事务传播性的几种定义 PROPAGATION_REQUIRED -- 支持当前事务,如果当前没有事务,就新建一个事务。这是最常见的选择。 PROPAGATION_SUPPORTS -- 支持当前事务,如果当前没有事务,就以非事务方式执行。 PROPAGATION_MANDATORY -- 支...

yanxin1213的博客 2万+

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

@Transactional中PROPAGATION_REQUIRES_NEW 和 PROPAGATION_NESTED区别

@Transactional1、Spring中对于事务传播性的定义2、PROPAGATION_REQUIRES_NEW 与 PROPAGATION_NESTED区别3、@Transactional主方法调用子方法事务的有无3.1 两个方法在同一个类中3.2 两个方法在不同类中 1、Spring中对于事务传播性的定义 PROPAGATION_REQUIRED:支持当前事务,如果当前没有事务,则新建一个事务 PROPAGATION_SUPPORTS:支持当前事务,如果当前没有事务,则以非事务进行 PROPAG

LuQiaoYa的博客 3265

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

Spring事务之7种传播行为

spring 事务传播行为

吴川华仔的博客 4236

看完就明白_spring事务的7种传播行为

原文:https://blog.youkuaiyun.com/soonfly/article/details/70305683事务传播行为什么叫事务传播行为?听起来挺高端的,其实很简单。 即然是传播,那么至少有两个东西,才可以发生传播。单体不存在传播这个行为。事务传播行为(propagation behavior)指的就是当一个事务方法被另一个事务方法调用时,这个事务方法应该如何进行。 例如:methodA事...

weixin_39625809的博客 14万+

Propagation.NESTED 和Propagation.REQUIRES_NEW的区别

Propagation.NESTED 和Propagation.REQUIRES_NEW的区别 首先感谢这个微博的博主,解决了我的疑惑。https://www.cnblogs.com/-flq/p/9768576.html 说到spring的事务传播行为,最难理解的不过是Propagation.REQUIRES_NEW和Propagation.NESTED了。上网搜了一下大家的描述,我自己总结...

aiyaya_66da的博客 4845

Spring事务的7种传播机制

什么叫事务传播机制?听起来挺高端的,其实很简单。即然是传播,那么至少有两个东西,才可以发生传播。单体不存在传播这个行为。事务传播行为(propagation behavior)指的就是,这个事务方法应该如何进行。例如:methodA事务方法调用methodB事务方法时,methodB是继续在调用者methodA的事务中运行呢,还是为自己开启一个新事务运行,这就是由methodB的事务传播行为决定的。

m0_45164511的博客 924

Spring 事务管理

在 SPRING 中一共定义了六种事务传播属性 PROPAGATION_REQUIRED -- 支持当前事务,如果当前没有事务,就新建一个事务。这是最常见的选择。 PROPAGATION_SUPPORTS -- 支持当前事务,如果当前没有事务,就以非事务方式执行。 PROPAGATION_MANDATORY -- 支持当前事务,如果当前没有事务,就抛出异常。 PROPAGATION_RE...

不甘平庸的人 1311

PROPAGATION_REQUIRES_NEW 和 PROPAGATION_NESTED区别

转载地址:https://blog.youkuaiyun.com/u011285162/article/details/19247711  最容易弄混淆的其实是 PROPAGATION_REQUIRES_NEW 和 PROPAGATION_NESTED, 那么这两种方式又有何区别呢? 我简单的翻译一下 Juergen Hoeller 的话 :           PROPAGATION_REQUIRES_N...

ncuzengxiebo的博客 3539
上一篇: springMVC使用HandlerMethodArgumentResolver 自定义解析器实现请求参数绑定方法参数
下一篇: Java回调机制解析
VagueCoder
博客等级 码龄13年 4粉丝 8原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值