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!