jta

Transactional annotation on whole class + excluding a single method

雨燕双飞 提交于 2019-11-29 16:36:20
问题 I have a class with @Transactional annotation (instead of marking it for all of its method). Although i have a single method inside that class that shouldn't be annotated as @Transactional . My question is is there an annotation i can put in this method to mark it as "non-transactional"? or should i start marking each single method in this class as "transactional" excluding this method (a lot of work) thanks. 回答1: There are different transaction propagation strategies to use. These exist in

[转]Spring引用Tomcat的 JTA事务

怎甘沉沦 提交于 2019-11-29 16:22:40
Spring引用Tomcat的 JTA 事务 Tomcat是Servlet容器,但它提供了JNDI的实现,因此用户可以象在Java EE应用程序服务器中一样,在Tomcat中使用JNDI查找JDBC数据源。在事务处理方面,Tomcat本身并不支持 JTA ,但是可以通过集成JOTM达到目的。 如果你的应用最终部署到一个功能齐备的Java EE应用服务器上,也许你更希望使用Java EE应用服务器的 JTA 功能,这样可以利用应用服务器本身许多优化措施。下面,我们让Tomcat通过JNDI开放JOTM的 JTA 的数据源,进而在Spring容器引用这个JNDI数据源,并在此基础上提供 JTA 事务。我们所使用的环境是:Tomcat 5.5+JOTM 2.3。 1. 添加所需的JAR文件 将JOTM以下类包添加到<Tomcat安装目录>/common/lib目录中: jotm.jar jotm_jrmp_stubs.jar jotm_iiop_stubs.jar ow_carol.jar jta -spec1_0_1.jar jts1_0.jar objectweb-datasource.jar xapool.jar howl.jar connector-1_5.jar 同时,还需要添加相应数据库的JDBC驱动类包,例如 MySQL 的 mysql .jar。 2. 配置JOTM

Spring引用Tomcat的 JTA事务

余生长醉 提交于 2019-11-29 16:22:27
Spring引用Tomcat的 JTA事务 Tomcat是Servlet容器,但它提供了JNDI的实现,因此用户可以象在Java EE应用程序服务器中一样,在Tomcat中使用JNDI查找JDBC数据源。在事务处理方面,Tomcat本身并不支持JTA,但是可以通过集成JOTM达到目的。 如果你的应用最终部署到一个功能齐备的Java EE应用服务器上,也许你更希望使用Java EE应用服务器的JTA功能,这样可以利用应用服务器本身许多优化措施。下面,我们让Tomcat通过JNDI开放JOTM的JTA的数据源,进而在Spring容器引用这个JNDI数据源,并在此基础上提供JTA事务。我们所使用的环境是:Tomcat 5.5+JOTM 2.3。 1. 添加所需的JAR文件 将JOTM以下类包添加到<Tomcat安装目录>/common/lib目录中: jotm.jar jotm_jrmp_stubs.jar jotm_iiop_stubs.jar ow_carol.jar jta-spec1_0_1.jar jts1_0.jar objectweb-datasource.jar xapool.jar howl.jar connector-1_5.jar 同时,还需要添加相应数据库的JDBC驱动类包,例如MySQL的mysql.jar。 2. 配置JOTM 新建一个carol

JPA with JTA: Persist entity and merge cascaded child entities

吃可爱长大的小学妹 提交于 2019-11-29 13:24:14
I have a bidirectional one-to-many relationship with the following entity classes: 0 or 1 client <-> 0 or more product orders When persisting the client entity I want the associated product order entities to be persisted, too (as their foreign key to the "parent" client may have been updated). Of course all required CASCADE options are set on the client side. But it does not work if a newly created client is persisted for the first time while referencing an existing product order as in this scenario: product order '1' is created and persisted. Works fine. client '2' is created and product

JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession()

ⅰ亾dé卋堺 提交于 2019-11-29 11:54:33
Using hibernate in my application, and everytime I do a transaction, I get this warning. It is spamming my logs. JTASessionContext being used with JDBCTransactionFactory; auto-flush will not operate correctly with getCurrentSession() I think it is caused by hibernate.current_session_context_class property. <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property> <property name="hibernate.connection.pool_size">5</property> <property name="show_sql">false</property> <property name="dialect">org.hibernate.dialect

Configuring EJB on JBoss AS 7 using JTA datasources: every statement is commited

寵の児 提交于 2019-11-29 07:58:04
everybody! I've been trying to find the answer for some time but I didn't manage. I try to configure my application and make it work under JBoss Application Server 7.1.1, using Enterprise Java Beans. My application is Web application, it uses servlets and injects other classes as EJBs. The problem is that every statement gets commited, so that means no transaction management is supported. In my test example I have an entity with a collection of children (mapped with a relationship OneToMany with a property CascadeType.ALL). If a record in a collection has some problems (e.g. non-existing

spring事务管理源码解析之namespaceHandler

独自空忆成欢 提交于 2019-11-29 05:26:43
说在前面 本文转自“天河聊技术”微信公众号 spring事务管理项目开发中都会用到,大家一般用的都是声明式事务管理,spring也集成jta全局事务管理的支持,用的比较少,本次主要针对声明式本地事务管理角度进行源码解析,有好的见解欢迎关注“天河聊技术”微信公众号,在微信公众号中找到我本人微信加入技术微信群进一步交流,你们的支持是我一直写下去的动力,如果觉得看完对自己有所帮助,也欢迎朋友圈转发,源码解析很痛苦,it生涯就是这样,这种痛苦也叫成长。 正文 事务管理器 本地事务基于jdbc的是org.springframework.jdbc.datasource.DataSourceTransactionManager 事务注解解析器 使用spring的事务管理,要先引入spring-tx包,那就先会加载org.springframework.transaction.config.TxNamespaceHandler,先简单看下这个类的内容 registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenBeanDefinitionParser()); 这行代码是对<tx:annotation-driven"/>标签的解析。 进入到这个类的这个方法 org.springframework.transaction

Is there an open-source solution to XA-transactional file access in Java?

北城余情 提交于 2019-11-29 03:43:27
问题 Is it possible to make XA-transactional access to the file system in Java? I want to manipulate files within the boundaries of a transaction and my transaction must participate in a distributed transaction via JTA (so I guess the file system needs to be accesses as a XAResource). I don't need support for fine-grained read/write file access; treating each file as a record is good enough for my needs. Does anybody know an open-source project that already does this? I don't feel like

dynamically register transaction listener with spring?

只愿长相守 提交于 2019-11-29 01:24:45
问题 I have a springframework application in which I would like to add a transaction listener to a transaction which is currently in progress. The motivation is to trigger a post commit action which notifies downstream systems. I am using @Transactional to wrap a transaction around some service method -- which is where I want to create/register the post transaction listener. I want to do something "like" the following. public class MyService { @Transaction public void doIt() { modifyObjects(); //

maven手工安装依赖包

大憨熊 提交于 2019-11-28 20:29:51
maven有时候自动添加依赖失败,部分jar包不支持自动添加,所以有时需要手工进行安装依赖,操作方法如下: 1.下载zip文件 2.进入zip文件所在目录,从本地安装 以jta-1.0.1B为例,本地手工安装命令如下:jta-1_0_1B-classes.zip为下载的zip文件名 mvn install:install-file -Dfile=./jta-1_0_1B-classes.zip -DgroupId=javax.transaction -DartifactId=jta -Dversion=1.0.1B -Dpackaging=jar 安装完成后,在eclipse工程中执行maven update dependency操作,即可。 来源: http://www.cnblogs.com/ycblus/p/5546088.html