春天的事务管理,图解事务传播行为

9.3.5 所需的传播行为 图最9-3 新  {      addressService.save(user.getAddress()); //将在同一个事务内执行 }赶上(RuntimeException的E)  userService.countAll());  Assert.assertEquals(1,addressService.countAll());  为如下形式: java的代码: Java的代码  尝试{      userService.save(用户);     Assert.fail();  }赶上(RuntimeException的E) {  }  Assert.assertEquals(0,userService.countAll()); Assert.assertEquals(0,  RequiresNew传播行为 图最9-5 TransactionTemplate的=  TransactionTemplate的= userService.countAll());  Assert.assertEquals(1,  新  userService.countAll()); Assert.assertEquals(1,addressService.countAll());  为如下形式: java的代码: Java的代码  尝试{      userService.save(用户);      Assert.fail();  }赶上(RuntimeException的E) {  }  Assert.assertEquals(0,userService.countAll());  Assert.assertEquals(1,  所需的+支持传播行为        图最9-7        需要+ NotSupported传播行为        图最9-9        需要+强制性传播行为        图最9-11        所需的+决不传播行为        图最9-13        需要+嵌套的传播行为 图最9-15嵌套+嵌套的传播行为 嵌套和RequiresNew的区别: 1,RequiresNew每次都创建新的独立的物理事务,而嵌套只有一个物理事务; 2,RequiresNew由于都是全新的事务,所以之间是无关联的; 3,嵌套使用JDBC 正确的事务只读设置 图最9-17 交易带的定义[......]没有被标记为 春天的事务之9.3编程式事务 226 积分:700    发表时间:10小时前最后修改:9小时前引用收藏 代理方式下的自我调用 图最9-18 修改TransactionProxyFactoryBean的配置定义,添加exposeProxy属性为真; 2,在业务方法内通过代理对象调用相应的事务方放,如 使用这种方式属于侵入式,不推荐使用,除非必要。 图9-19代理方式下的自我调用 
posted @ 2014-12-23 22:51  JAVA之迷  阅读(172)  评论(0编辑  收藏  举报