jta

JTA or LOCAL transactions in JPA2+Hibernate 3.6.0?

醉酒当歌 提交于 2019-12-03 07:41:00
We are in the process of re-thinking our tech stack and below are our choices (We can't live without Spring and Hibernate due to the complexity etc of the app). We are also moving from J2EE 1.4 to Java EE 5. Technology stack Java EE 5 JPA 2.0 (I know Java EE 5 only supports JPA 1.0 but we want to use Hibernate as the JPA provider) Hibernate 3.6.0 (We already have lots of hbm files with custom types etc. so we doesn't want to migrate them at this time to JPA. This means we want both jpa/hbm mappings work together and hence the Hibernate as the JPA provider instead of using the default that

Difference between UserTransaction and EntityTransaction

点点圈 提交于 2019-12-03 05:51:39
问题 Title says it all: What is the difference between a UserTransaction and an EntityTransaction ? My rudimentary understanding is that UserTransaction is used when JTA is required (e.g. to do queries on mulitple things), and that EntityTransaction is used when JPA only is required (e.g. when the query is atomic). Is that the only difference between the two or is there more to it than that? 回答1: My rudimentary understanding is that UserTransaction is used when JTA is required (e.g. to do queries

JTA分布式事务实践

喜夏-厌秋 提交于 2019-12-03 05:25:08
最近一直在研究怎么实现分布式事务,花了不少时间,测试工程启停测试了无数次,最终实现的时候其实也就是写一些配置文件,对于工程代码没什么影响。目前研究还不是很深入,对于全面崩溃恢复如何实现和测试还不清楚。本文先介绍基础的实现。 当业务需要在一个事务中操作多个不同的资源,例如多个 数据库 ,消息队列,缓存等,那么就需要使用分布式事务了。在 Java 中一般建议使用 JTA ,这样开发人员就不用关心什么叫 XA 协议,什么是两阶段提交协议。要使用 JTA 需要容器的支持,例如使用 JBOSS,WebSphere ;或者使用第三方组件例如 JOTM 、 Atomikos 。 JBOSS AS 现在改名叫 Wildfly 了,以便和 JBOSS EAP 区分,后文我也改叫 Wildfly 。 JOTM 看起来是个死项目,我不打算使用。 由于目前开发框架基于 spring +JPA 设计,所以本文的配置主要是在 spring 中。其实用 EJB 的话配置更简单,但需要容器支持。 一、Wildfly 中配置 JTA 1、 配置数据库驱动( oracle ) a) 首先按照以下路径新增目录: wildfly-9.0.0.CR1\modules\system\layers\base\com\oracle\ojdbc14\main b) 把驱动文件 ojdbc14.jar 复制到此目录下 c) 在

persistence.xml for multiple persistence units

你。 提交于 2019-12-03 03:27:33
I'm trying to persist the same entity to both MySQL and Postgres databases (this is primarily to identify any inconsistencies, and work out the details of any issues doing the dual-write -- which I've run into here). The articles I've found have all described solutions that depend on additional frameworks. I'm trying to solve this using Glassfish 4.0 out-of-the-box, JPA 2.1 with EclipseLink 2.5 as the JPA provider. I'm using Eclipse, and realize that the IDE doesn't support configuring multiple persistence units in the persistence.xml file, so I'm writing the XML for that directly. I was

JAVA之JDBC简单事务处理

南楼画角 提交于 2019-12-03 03:26:20
1、什么是Java事务 通常观念认为,事务与数据库有关。 事务是访问数据库的一个操作序列,数据库应用系统通过事务集来完成对数据库的存取。事务的正确执行使得数据库从一种状态转换成另一种状态。 事务必须服从ISO/IEC所制定的ACID原则。ACID是原子性(atomicity)、一致性(consistency)、隔离性(isolation)和持久性(durability)的缩写事务必须服从ISO/IEC所制定的ACID原则。ACID是原子性(atomicity)、一致性(consistency)、隔离性(isolation)和持久性(durability)的缩写。 a 、 原子性 即不可分割性,事务要么全部被执行,要么就全部不被执行。如果事务的所有子事务全部提交成功,则所有的数据库操作被提交,数据库状态发生转换;如果有子事务失败,则其他子事务的数据库操作被回滚,即数据库回到事务执行前的状态,不会发生状态转换。 b 、 一致性 事务的执行使得数据库从一种正确状态转换成另一种正确状态。 c、 隔离性 在事务正确提交之前,不允许把该事务对数据的任何改变提供给任何其他事务,即在事务正确提交之前,它可能的结果不应显示给任何其他事务。 d 、 持久性 事务正确提交后,其结果将永久保存在数据库中,即使在事务提交后有了其他故障,事务的处理结果也会得到保存。    既然事务的概念从数据库而来

深入Java 事务的原理与应用

橙三吉。 提交于 2019-12-03 03:26:05
一、什么是 JAVA 事务 通常的观念认为,事务仅与数据库相关。 事务必须服从ISO/IEC所制定的ACID原则。ACID是原子性(atomicity)、一致性(consistency)、隔离性 (isolation)和持久性(durability)的缩写。事务的原子性表示事务执行过程中的任何失败都将导致事务所做的任何修改失效。一致性表示 当事务执行失败时,所有被该事务影响的数据都应该恢复到事务执行前的状态。隔离性表示在事务执行过程中对数据的修改,在事务提交之前对其他事务不可见。持 久性表示已提交的数据在事务执行失败时,数据的状态都应该正确。 通俗的理解,事务是一组原子操作单元,从数据库角度说,就是一组SQL指令,要么全部执行成功,若因为某个原因其中一条指令执行有错误,则撤销先前执行过的所有指令。更简答的说就是:要么全部执行成功,要么撤销不执行。 既然事务的概念从数据库而来,那Java事务是什么?之间有什么联系? 实际上,一个Java应用系统,如果要操作数据库,则通过JDBC来实现的。增加、修改、删除都是通过相应方法间接来实现的,事务的控制也相应转移到Java程序代码中。因此,数据库操作的事务习惯上就称为Java事务。 二、为什么需要Java事务 事务是为解决数据安全操作提出的,事务控制实际上就是控制数据的安全访问。举一个简单例子:比如银行转帐业务

Propagation of Oracle Transactions Between C++ and Java

一个人想着一个人 提交于 2019-12-03 03:06:29
We have an existing C++ application that we are going to gradually replace with a new Java-based system. Until we have completely reimplemented everything in Java we expect the C++ and Java to have to communicate with each other (RMI, SOAP, messaging, etc - we haven't decided). Now my manager thinks we'll need the Java and C++ sides to participate in the same Oracle DB transaction. This is related to, but different from the usual distrbuted transaction problem of having a single process co-ordinate 2 transactional resources, such as a DB and a message queue. I think propagating a transaction

How to get rid of the border with a JTable / JScrollPane

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: If you run the small sample below you'll see a border around the center region. I'm not sure why this border is showing. It happens when a JTable is in a JScrollPane. I tried various things to remove it but so far no luck. A JTable without the JScrollPane shows no border. See sample below. TIA. public class TestScrollPane extends JFrame { public static void main(String[] args) { JFrame frame = new TestScrollPane(); JPanel panel = new JPanel(); JTable table = new JTable(); panel.setLayout(new BorderLayout()); panel.add(new JLabel("NORTH"),

Spring IllegalStateException: A JTA EntityManager cannot use getTransaction()

匿名 (未验证) 提交于 2019-12-03 02:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So after a big refactoring project, I am left with this exception and am unsure as how to correct it. It's dealing with some code that I did not write and I am unfamiliar with how it all works. There are other questions out there dealing with this exception, but none seem to fit my situation. The class which uses EntityManager is SpecialClaimsCaseRepositoryImpl : package com.redacted.sch.repository.jpa; //Imports @Repository public class SpecialClaimsCaseRepositoryImpl extends SimpleJpaRepository<SpecialClaimsCaseDto, SpecialClaimsCaseDto.Id

A JTA EntityManager cannot use getTransaction()

匿名 (未验证) 提交于 2019-12-03 02:00:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: How do I have the following code in my non-ejb application. The code works. @Override public void saveItems(Collection items) { synchronized (em) { EntityTransaction tx = em.getTransaction(); try { tx.begin(); for (T item : items) { saveItem_((Class ) null, item); } tx.commit(); } finally { if (tx.isActive()) { tx.rollback(); } } } } In a new application I'm using EJB3 + JSF and would like to re-use the library containing the code above. My peristence unit for the new application looks like this: org.hibernate.ejb.HibernatePersistence