jta

Java Distribute Transaction

I want to rollback a transaction which already committed, does JTA support this kind of function? ...

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

Hi 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 understa...

How to manage transaction for database and file system in jee environment?

I store file’s attributes (size, update time…) in database. So the problem is how to manage transaction for database and file. In jee environment, JTA is just able to manage database transaction. In case, updating database is successful but file operation fails, should I write file-rollback method for this? Moreover, file operation in ...

Using injected EntityManager in class hierarchies

The following code works: @Stateless @LocalBean public class MyClass { @PersistenceContext(name = "MyPU") EntityManager em; public void myBusinessMethod(MyEntity e) { em.persist(e); } } But the following hierarchy gives a TransactionRequiredException in Glassfish 3.0 (and standard JPA ...

What is difference between @Resource UserTransaction and EntityManager.getTransaction()

Hello, Can anybody explain what is difference between : @Resource UserTransaction objUserTransaction; and EntityManager.getTransaction(); And also what is container managed transaction? and how should I do it in my session facade if I want to insert three rows in table in transaction. ...

How to use JTA support in Tomcat 6 for Hibernate ?

They recommend using JTA transaction support in JEE environment. But how to configure JTA in Tomcat6 so that Hibernate Session could use it ? Starting with version 3.0.1, Hibernate added the SessionFactory.getCurrentSession() method. Initially, this assumed usage of JTA transactions, where the JTA transaction defined both the scope a...

Best Tomcat6 JNDI + Hibernate configuration for session/transaction support

Quote from hib official docs: Starting with version 3.0.1, Hibernate added the SessionFactory.getCurrentSession() method. Initially, this assumed usage of JTA transactions, where the JTA transaction defined both the scope and context of a current session. Given the maturity of the numerous stand-alone JTA TransactionManager implementa...

Implement custom JTA XAResource for using with hibernate

I have two level access to database: the first with Hibernate, the second with JDBC. The JDBC level work with nontransactional tables (I use MyISAM for speed). I want make both levels works within transaction. I read about JTA which can manage distributed transactions. But there is lack information in the internet about how to implement ...

Defines JEE 5 the handling of commit error using bean managed transactions?

I'm using glassfish 2.1 and 2.1.1. If I've a bean method annotated by @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW). After doing some JPA stuff the commit fails in the afterCompletion-Phase of JTS. GlassFish logs this failure only. And the caller of this bean method has no chance to know something goes wrong. So...

Looking for a NoSQL DB with JTA support

Are there any reliable and well-known NoSQL DBs available that support JTA transactions? In my application I need to store some data to the RDBMS DB and some data to the NoSQL DB in the same transaction and I am using JTA for my RDBMS transactions. ...

How to write automated integrated tests when using JTA?

I want to write integration tests for the application I'm working on. It uses JTA (multiple resources) and runs inside an application server. What is the best way for writing an automated test for such a scenario? Using an standalone transaction manager like atomikos or somehow leveraging the app server api/tools for transaction handling...

How can i attach data to a JTA transaction? (or uniquely identify it)

I have a getStockQuote() function that will get a current stock quote for a symbol from the stock market. My goal is that within a JTA transaction, the first call to getStockQuote() will fetch a stock quote, but all subsequent calls within the same transaction will reuse the same stock quote (e.g.: it will not try to fetch a new quote)....

JTA Transaction: What happens if an exception happens but rollback is not called on the transaction?

We have some third party code wherein they do the following 1) Create a User Transaction e.g. txn = (UserTransaction)ctx.lookup( "UserTransaction" ); txn.begin( ); 2) Do some work persisting to the database (via JPA) to a MySQL database 3) txn.commit() They have Exception blocks but NONE of them call txn.rollback. Good c...

Atomikos vs JOTM vs Bitronix vs ????

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 manager? In those environments, would you still use these third p...

Should integration testing of DAOs be done in an application server?

I have a three tier application under development and am creating integration tests for DAOs in the persistence layer. When the application runs in Websphere or JBoss I expect to use the connection pooling and transaction manager of those application servers. When the application runs in Tomcat or Jetty, we'll be using C3P0 for pooling...

How to obtain JNDI data source for JPA/JTA DAO integration test?

I have a JPA application that has specified JTA transactions in persistence.xml. For whatever reason, I have found that when using JTA, you MUST specify a JNDI data source within persistence.xml as well. This is fine, unless you are trying to go integration testing outside a container and JNDI is not available. My questions are: a) i...

Problem creating JPA EntityMananger in Spring Context

I have a JPA/Spring application that uses Hibernate as the JPA provider. In one portion of the code, I have to manually create a DAO in my application with the new operator rather than use Spring DI. When I do this, the @PersistenceContext annotation is not processed by Spring. In my code where I create the DAO I have an EntityManager...

Atomikos rollback doesn't clear JPA persistence context?

I have a Spring/JPA/Hibernate application and am trying to get it to pass my Junit integration tests against H2 and MySQL. Currently I am using Atomikos for transactions and C3P0 for connection pooling. Despite my best efforts my DAO integration one of the tests is failing with org.hibernate.NonUniqueObjectException. In the failing ...

Java: Difference betwen UserTransaction and EntityTransaction

Title says it all: What is the difference between a UserTransaction and a 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...

Options for using Spring, Hibernate, JPA, and Tomcat with multiple Databases

I have a java web app running under Spring 2.5.6, Hibernate 3.4 (with Hibernate as the JPA provider), and Tomcat 6. I have it working with one DB schema / persistence unit but now need to connect to 2 schemas / persistence units. Can I do this without moving to a J2EE container such as JBoss or Glassfish? Will I need to use something lik...