Transaction setTimeOut ignored in JTA environment

元气小坏坏 提交于 2019-12-13 18:14:13

问题


We have a problem setting transaction timeout on specific operations, overriding the general timeout in an application with Hibernate 4.2.1 and Jboss 7AS, since we find values set with "setTimeOut" are ignored.

We have a JTA non-CMT persistence unit like this:

<persistence-unit name="ourName" transaction-type="JTA">
  <provider>org.hibernate.ejb.HibernatePersistence</provider>
  <jta-data-source>java:/datasources/ourDataSourceName</jta-data-source>
  <properties>
        <property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>
        <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
        <property name="hibernate.show_sql" value="false" />
        <property name="hibernate.format_sql" value="false" />
  </properties>
</persistence-unit>

Then we declare the persistenceUnit like this:

@PersistenceUnit(unitName="ourName")
private EntityManagerFactory emf;

And get the sessionFactory from it. With such sessionFactory, we open a session and get a transaction into which we set the time-out before beginning it:

session = sessionFactory.openSession ();
tx = session.getTransaction ();
tx.setTimeout (200);
tx.begin ();

In our standalone.xml config file we set the global timeout as (the 10s. displayed value is just for testing, of course):

coordinator-environment enable-statistics="true" default-timeout="10"/>

The result is that no matter the values we set via "setTimeOut", a timeout of 10 seconds always applies.

Anyone out there with ideas of what we are doing wrong would be greatly appreciated!

Thx!

来源:https://stackoverflow.com/questions/19227662/transaction-settimeout-ignored-in-jta-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!