jta

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

假装没事ソ 提交于 2019-12-06 11:58:43
问题 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) is there anyway to inject a jdbc datasource into my JTA transaction manager? b) if not, how do a handle a JNDI lookup during integration testing? Edit: The error I

How to fix HSQL DataSource + TxM where identity always return 0

筅森魡賤 提交于 2019-12-06 11:24:38
I am using Hibernate to do my ORM stuff w/ HSQL for tests. It seems that a connection is fetched to do the insert and then returned. Straight after that HIbernate gets a connection then tries to fetch the identity from HSQL but that returns 0 which is obviously wrong. WHen i was running w/out a tm and datasource using a plain pooled connection everything worked but with the new tm + ds i am getting this problem. The answer is the DataSource should be tx aware, so that connections are sticky for each new tx. The original problem was a different connection was used to fetch the identity of the

Does jboss handle managed Entity Manager concurrency issues for me?

纵然是瞬间 提交于 2019-12-06 10:28:10
问题 It seems that the Entity Manager instance jboss manages and provides is a proxy to the actual implementation bound to a persistence context. This actual implementation gathers the isolation provided by JTA transactions (per transaction contexts). That makes me think I don't need to worry about concurrency issues when dealing with the proxy instance. Maybe I can even cache this proxy instance if I decide to bring it from JNDI lookups instead of container injection? Is that reasonable? 回答1: The

How to use JDBC in JavaEE?

穿精又带淫゛_ 提交于 2019-12-06 09:28:41
I'm developing in a JavaEE environment (weblogic 12), and part of my code uses JDBC; Therefore, I need to aqcuire a JDBC connection from the application server. I know it's a really bad practice to use JDBC in JavaEE, but that's a code I cannot change (legacy). I've found a way to do it, but I'm not sure it's the right way: @Resource(mappedName="mydsjndipath") private DataSource ds; public void foo() { Connection conn = ds.getConnection(); } The question is what do I do with the connection at the end? I can't really commit/rollback it, because I use a distributed transaction. But should I at

Why does not commit transaction of Requires_New?

断了今生、忘了曾经 提交于 2019-12-06 09:05:57
I have a problem. I am working on java application server(sap netweaver) with I am using ejb 3.0 So I want to database insert one by one. Because I have too much data and i have to divide data. So I made try test code and it did work but it did not work as I want. I want to create a new transaction for each part and of course at the end method(transaction) should be commit. Sample code is below; package com.transaction.jobs; import javax.ejb.Local; /** * * @author muratdemir */ @Local public interface TestTransactionLocal { public void onStart(); public void insertObject(int i); } and package

Spring4 + Hibernate4 + JTA Write Operations Fail

杀马特。学长 韩版系。学妹 提交于 2019-12-06 08:36:30
I am migrating a legacy Spring 3, Hibernate 3, JTA on JBoss 5 application to the latest versions (Spring 4.1.0.RELEASE, Hibernate 4.3.6.Final, JBoss Wildfly 8.1). It seems that Spring 4.1.0.RELEASE and Hibernate 4.3.6.Final do NOT work together in supporting transactions for write operations with the LocalSessionFactoryBean and the HibernateTransactionManager as configured below. Read-only get operations appear to be working ok. To migrate, org.springframework.orm. hibernate3 .support.HibernateDaoSupport has been updated to org.springframework.orm. hibernate4 .support.HibernateDaoSupport. The

Failing to merge date on Eclipselink

北城余情 提交于 2019-12-06 08:22:43
问题 My session bean does not execute an update on a managed entity. I have included code for the classes concerned. When I modify the date field of an event by using a prime faces schedule component and pass the modified entity to a session bean and call em.merge(event) the entity manager does not attempt to update the entity and no changes are registered in the database. Session Bean @Stateless @LocalBean public class CalendarSessionBean implements Serializable { @PersistenceContext private

Hibernate JPA with JTA and Glassfish Application Server doesn't seem to commit

杀马特。学长 韩版系。学妹 提交于 2019-12-06 07:23:47
问题 I'm new to hibernate and I want it to use the database connection from the application server via JNDI. The Strange thing is, that it creates my tables in the database but it doesn't save the entity. It seems, that it doesn't commit. Has someone experienced similar problems with hibernate? This is a little test-servlet: public class WriteTest extends HttpServlet { @Override public void doGet(HttpServletRequest request, HttpServletResponse response) { /*try { User user = new User("Hans",

NamingException: jta.UserTransaction

巧了我就是萌 提交于 2019-12-06 04:33:18
I have a hibernate application which directly uses Java Transaction API resources. I'm trying to use UserTransaction to accomplish some basic database transactions The UserTransaction interface defines the methods that allow an application to explicitly manage transaction boundaries In hibernate.cfg.xml file I have the following properties: <session-factory> <property name="show_sql">true</property> <property name="connection.datasource">java:comp/env/myDataSource</property> <property name="jta.UserTransaction">java:comp/UserTransaction</property> <property name="transaction.factory_class">org

Why to use jpadialect in JpaTransactionManager

断了今生、忘了曾经 提交于 2019-12-06 04:09:46
I am learning spring 3.0 from Spring in Action. There it talks about importance of having jpadialect in JpaTranactionManager <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> <property name="jpaDialect" ref="jpaDialect" /> </bean> <bean id="jpaDialect" class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" /> However the dialect is already present in declaration of entityManagerFactory via jpaVendorAdaptor. <bean id="entityManagerFactory" class= "org.springframework.orm.jpa