jta

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

半城伤御伤魂 提交于 2019-12-12 18:54:59
问题 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 like JOTM and global / XA transactions? 回答1: If you need to access multiple transactional resources within the same transaction, you'll need JTA and thus a JTA

Can I use JTA over different EARs which are deployed to different servers?

情到浓时终转凉″ 提交于 2019-12-12 18:02:47
问题 I'm looking into JTA as I need distributed transactions (across JPA, JMS and EHCache). I'm trying to understand whether JTA can supply an additional functionality which I'm considering. If I have 3 different servers, each running Glassfish and each server has a different EAR (a different module of mine). Can I have a transaction which will span across different servers and different EARs? Thanks, Ittai 回答1: Can I have a transaction which will span across different servers and different EARs?

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

浪尽此生 提交于 2019-12-12 12:08:30
问题 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). If a different transaction starts, or another transaction runs concurrently, i would expect the other transaction to fetch its own stock quote on its first

Accessing transaction status in container managed beans

孤街浪徒 提交于 2019-12-12 10:59:59
问题 I have a @Stateless EJB using container managed transaction. Is there a way to access the "status" of javax.transaction.UserTransaction ? That is, calling UserTransaction.getStatus() inside the bean methods? I know access to UserTransaction is prohibited in container managed beans, but I would like to know, is there any other way to get access to getStatus() method? 回答1: I don't think you've understood the responsibility of the UserTransaction class. It does not exist to provide you with

How to get jpa datasource properties from Entity Manager

二次信任 提交于 2019-12-12 10:42:59
问题 Hi everybody I was wondering if it's possible to get database connection properties through entity manager. My persistence.xml looks like this <persistence ...> <persistence-unit name="default" transaction-type="JTA"> <jta-data-source>DatasourceForTestSystem</jta-data-source> <class> some.package.and.some.Class </class> ... </persistence-unit> </persistence> I want something like String host = em.getSomeFunction().getProperties().get("server"); String database = em.getSomeFunction()

Spring java config with JTA transaction

徘徊边缘 提交于 2019-12-12 05:25:42
问题 I writing a simple project in Spring and I want use JTA transaction. I want to java class base config, not xml. I search in Internet good configuration, but I don't find any interesting tutorial. My config class: package pl.airlines.configuration; import java.util.Properties; import javax.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.springframework.core.env.Environment; import org.springframework.beans.factory.annotation.Autowired; import org.springframework

springboot jta transaction rollback is not working

廉价感情. 提交于 2019-12-12 04:46:38
问题 I want to perform transaction across database using JTA (using atomikos) configuration. I have below code which I wanted to perform in one transaction. However when I run the application, it saves entityObject1 and update eventObject2 and doesnt rollback when an exception is thrown when i run l.intValue() statement. below is all code that I am using with configuration for JTA. Am i missing anything? Could anyone please help. public void testJTATRansaction() { service1.saveEvent1(eventObject1)

SPRING, JPA(EclipseLink) with JTA Transaction Manager(JBoss 7) - NOT Committing to Database

淺唱寂寞╮ 提交于 2019-12-12 04:37:59
问题 I have created an example - SPRING, JPA(EclipseLink persistence provider) with JTA Transaction Manager(JBoss 7). I have observed that all the data in database is being shown in UI properly for the read operations. But when it comes to save/update or delete operation the services layer is not committing the work to database. No exception is caught(I have checked the console/log too and also debugged the code where I can see entityManager.persist/remove is being invoked without any exception).

joinTransaction has been called on a resource-local EntityManager in JBoss

点点圈 提交于 2019-12-12 04:37:09
问题 I have earlier worked with application-managed RESOURCE-LOCAL transaction but now I want to use container-managed JTA transaction. Everything seems to be ok while I am using @Stateless but as soon as I use @Stateful I get an exception as below javax.ejb.EJBException: javax.persistence.TransactionRequiredException: joinTransaction has been called on a resource-local EntityManager which is unable to register for a JTA transaction. I am using JBoss eap 6.2 with eclipselink2.5 and Java8 and

JPA - multiple persistence units

半腔热情 提交于 2019-12-12 02:53:15
问题 I'm using JPA and I am connecting to multiple databases. Below is the persistence.xml - <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"> <persistence-unit name="myRead" transaction-type="RESOURCE_LOCAL"> <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider> <properties> <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" /> <property name="hibernate.show_sql" value="true" /> </properties> </persistence-unit> <persistence