为什么80%的码农都做不了架构师?>>>   

Spring with multiple transaction managers


Here is repost of http://stackoverflow.com/questions/4423125/spring-is-it-possible-to-use-multiple-transaction-managers-in-the-same-applica question.

Here is applicationContext.xml config part:

view plain copy to clipboard print ?
  1. <code><bean id="transactionManager1" class="org.springframework.orm.jpa.JpaTransactionManager">
  2. <property name="entityManagerFactory" ref="entityManagerFactory1" />
  3. <qualifier value="account"/>
  4. </bean>
  5. <bean id="transactionManager2" class="org.springframework.orm.jpa.JpaTransactionManager">
  6. <property name="entityManagerFactory" ref="entityManagerFactory2" />
  7. <qualifier value="businessData"/>
  8. </bean></code>

and code using:

view plain copy to clipboard print ?
  1. public class TransactionalService {
  2. @Transactional("account")
  3. public void setSomethingInAccount() { ... }
  4. @Transactional("businessData")
  5. public void doSomethingInBusinessData() { ... }
  6. }

So, as you see we can simply use several connections with transaction management in Spring application.

See also,
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/transaction.html#tx-multiple-tx-mgrs-with-attransactional
Enjoy!

转载于:https://my.oschina.net/dongwq/blog/182884

Spring with multiple transaction managers相关推荐

  1. Spring JTA multiple resource transactions in Tomcat with Atomikos example--转载

    原文地址:http://www.javacodegeeks.com/2013/07/spring-jta-multiple-resource-transactions-in-tomcat-with-a ...

  2. spring事务管理-Transaction模板(了解)

    那就迫切的需要事务来进行管理了,给大家演示在Spring中,要给咱们Service加事务,怎么加,现在是不是还没有加事务的,现在没有加事务,怎么加,我们要演示三种方式,三种方式 演示完,Spring管 ...

  3. 【Spring】21、用spring目标对象处理Transaction rolled back because it has been marked as rollback-only...

    在使用spring做事务管理时,很多人都会遇到这样一段异常: org.springframework.transaction.UnexpectedRollbackException: Transact ...

  4. Spring嵌套事务异常Transaction rolled back because it has been marked as rollback-only

    项目场景: 在循环里面使用try-catch去捕获异常的时候,并且try里面调的方法它也使用了事务注解 @transactional或者用了事务切面AOP去实现方法事务注入 问题描述 我这里的业务需求 ...

  5. spring事务操作Transaction

    web层 service(事务逻辑层)业务操作 创建转账的方法,调用dao的两个方法 Dao层(数据访问层)数据库操作,无业务操作,创建两个方法,(1)少钱(2)多钱 事务操作 1.事务添加到java ...

  6. 【Spring】actual transaction available for current thread - cannot reliably process ‘remove‘ call

    1.场景1 1.1 概述 一段代码大概是这样的 service 层 @Transactional public void delAndAdd(){repo1.deleteByModule(" ...

  7. spring Transaction Management --官方

    原文链接:http://docs.spring.io/spring/docs/current/spring-framework-reference/html/transaction.html 12.  ...

  8. Spring Transaction : TransactionAspectSupport

    概述 TransactionAspectSupport 是Spring的事务切面逻辑抽象基类,该类实现了事务切面逻辑,但是自身设计为不能被直接使用,而是作为抽象基类被实现子类使用,应用于声明式事务使用 ...

  9. Spring Boot JPA 中transaction的使用

    文章目录 @Transactional的实现 @Transactional的使用 Transaction的传播级别 REQUIRED SUPPORTS MANDATORY NEVER NOT_SUPP ...

  10. spring 事物的传播特性

    2019独角兽企业重金招聘Python工程师标准>>> 在使用spring事物通常会配置的Service层 ,当我们调用 一个service成的方法的时候 ,这个方法在执行的过程中对 ...

最新文章

  1. 使用 TListView 控件(3)
  2. tensorflow常用函数解析
  3. php 词法分析,【PHP7源码学习】2019-03-20 PHP词法分析
  4. ajax请求失败后重连和promiseIfy
  5. hdu 1404/zoj 2725 Digital Deletions 博弈论
  6. 1号店11.11:从应用架构落地点谈高可用高并发高性能
  7. nohup: 无法运行命令 ‘/bin/java‘: 没有那个文件或目录
  8. linux如何挂载U盘
  9. CF1110E-Magic Stones【结论题,差分】
  10. JBoss 4.2.x Spring 3 JPA Hibernate教程第2部分
  11. Leetcode-2 两数相加【c语言】
  12. 2018湖北技能高考计算机类学校,武汉船舶职业技术学院举行2018年湖北省技能高考...
  13. pycharm 文件修改的星号(*)提示||文件是否修改过
  14. MacOS入门技巧分享
  15. 开源一套基于 React Naitve 的业务驱动型 UI 组件库:react-native-atlas
  16. 三足鼎立 – Mac 输入法横向对比
  17. sobel 边缘检测 c++实现
  18. delln4030安装固态硬盘_戴尔灵越怎么更换固态硬盘
  19. NEO主要技术社区成员大曝光
  20. 远程监控养猪监控系统

热门文章

  1. 关于静态事件 static event 的二三事
  2. ASP.NET 页面传值方法的一些事情儿。
  3. fedora15下GNOME3使用笔记
  4. java提取(获取)博客信息(内容)
  5. 2019 支付宝App支付 --- PHP
  6. Java内存溢出定位和解决方案(new)
  7. CSS样式表——列表与布局
  8. 一个很方便使用十六进制的颜色值的宏
  9. smarty 模板不能正常加载css,js的问题
  10. 解决微信小程序要求TLS版本不低于1.2问题