jta

Why nested transactions are not supported in JTA

旧城冷巷雨未停 提交于 2019-12-18 15:41:06
问题 Why aren't nested transactions supported by JTA? Is it because of the complexity of implementing them (which I doubt) or some design principle? 回答1: (As @Piotr Nowicki points out, JTA does allow nested transactions, but this is optional not mandatory.) Why? This is one of those questions that is impossible to answer with any certainty, unless you were one of the people "in the room" when the decisions were made. It could be the inherent complexity of including nested transactions as part of

If I access UserTransaction does this mean that I use 2 phase commit or XA?

℡╲_俬逩灬. 提交于 2019-12-18 13:47:30
问题 UserTransaction ut=lookup.... ut.beginTransaction(); saveToFooDB(); statelessEjb.transactionSupportedMethod(); //saves something to the Foo DB saveToFooDB(); ut.commit(); If i was doing the above then my understanding is that it is not an XA transaction as it doesn't span across multiple resources (like DB plus JMS). Is my understanding correct? 回答1: Data source can be configured of two kinds: XA : these datasource can participate in distribute transactions Local : also called non-XA, they

Why different persistence units with separated data sources query the same data source?

匆匆过客 提交于 2019-12-18 10:20:13
问题 I'm developing a webapp which needs access to two different database servers (H2 and Oracle). The container is an Apache Tomee 1.5.1 and I'm using the Java EE stack with libraries provided in it (JSF, JPA, CDI, EJB, etc.). I'm trying to use two entity managers inside an XA transaction to extract data from the Oracle database and persist it in the H2 after transforming it, BUT all the queries are executed against the H2 database no matter the entity manager I use. Any help? EDIT : I found that

Cannot use an EntityTransaction while using JTA

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 05:42:33
问题 I'm receiving this error: javax.servlet.ServletException: java.lang.IllegalStateException: Exception Description: Cannot use an EntityTransaction while using JTA. While trying to use JPA and JAVAEE, Glassfish. My persistence.xml file is as follow: <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml

Cannot use an EntityTransaction while using JTA

北城余情 提交于 2019-12-18 05:41:11
问题 I'm receiving this error: javax.servlet.ServletException: java.lang.IllegalStateException: Exception Description: Cannot use an EntityTransaction while using JTA. While trying to use JPA and JAVAEE, Glassfish. My persistence.xml file is as follow: <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml

What is the difference between JTA and a local transaction?

瘦欲@ 提交于 2019-12-17 21:25:26
问题 What is the difference between JTA and a local transaction? An example that shows when to use JTA and when to use a local transaction would be great. 回答1: JTA is a general API for managing transactions in Java. It allows you to start, commit and rollback transactions in a resource neutral way. Transactional status is typically stored in TLS (Thread Local Storage) and can be propagated to other methods in a call-stack without needing some explicit context object to be passed around.

EntityManager doesn't see changes made in other transactions

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-17 20:27:48
问题 I'm writing some application for GlassFish 2.1.1 (JavaEE 5, JPA 1.0, as far as I know). I have the following code in my servlet (which I mostly borrowed from some sample on the Internet): @PersistenceContext(name = "persistence/em", unitName = "pu") private EntityManager em; @Resource private UserTransaction utx; @Override protected void doPost(...) { utx.begin(); . . . perform retrieving operations on em . . . utx.rollback(); } web.xml has the following in it: <persistence-context-ref>

How does UserTransaction propagate?

本小妞迷上赌 提交于 2019-12-17 18:07:11
问题 I have a stateless bean with bean-managed transactions, and a method like this: @Stateless @TransactionManagement(TransactionManagementType.BEAN) public class ... { @Resource private UserTransaction ut; @EJB private OtherStatelessBeanLocal other; public void invokeSomeMethods() ut.begin(); ... // invoke other bean's methods here. other.method(); ... ut.commit(); } } So how does the UserTransaction propagate to the OtherStatelessBeanLocal bean? 回答1: The UserTransaction object is an object

Atomikos vs JOTM vs Bitronix vs? [closed]

北战南征 提交于 2019-12-17 15:27:33
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 years ago . I am new to JTA and it's underlying transaction managers. Can anyone explain the pros/cons of each of these? Feel free to add others I didn't list in title. Also, don't the major applications servers (WebSphere, JBoss, Glassfish) have their own JTA compliant transaction

Persistence unit as RESOURCE_LOCAL or JTA?

折月煮酒 提交于 2019-12-17 02:40:21
问题 I have queries as below: What is the difference of these two? Are both of these supported by all databases? Are JPA TransactionManager and JTA TransactionManager different? 回答1: JPA implementations have the choice of managing transactions themselves ( RESOURCE_LOCAL ), or having them managed by the application server's JTA implementation. In most cases, RESOURCE_LOCAL is fine. This would use basic JDBC-level transactions. The downside is that the transaction is local to the JPA persistence