-
Feature Request
-
Resolution: Obsolete
-
Major
-
JBossAS-4.0.2 Final
-
None
-
mysql 4.1.11 as the datasource, hibernate service driving web application inside an EAR
-
Compatibility/Configuration
I would like to use Hibernate transactions in my code, since I need to run it stand-alone as well as inside JBoss. To support this, I need to use the org.hibernate.transaction.JDBCTransactionFactory, so I'd like to be able to configure the mbean like this (note last attribute is NOT supported by current hardeployer):
<server>
<mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.har:service=PdbHibernate">
<attribute name="DatasourceName">java:jdbc/OrMappingDS</attribute>
<attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute>
<attribute name="SessionFactoryName">java:/hibernate/PdbFactory</attribute>
<attribute name="JdbcBatchSize">100</attribute>
<attribute name="MaxFetchDepth">3</attribute>
<attribute name="ShowSqlEnabled">true</attribute>
<attribute name="TransactionStrategy">org.hibernate.transaction.JDBCTransactionFactory</attribute>
</mbean>
</server>
I noticed in the source code (see below) that you look in the environment for TRANSACTION_STRATEGY, but I'm not sure if I, as a user, can set that varaiable (is it an operating-system environment var? or a java -D var?) but anyway it would be nice to be able to configure it from the hibernate-service.xml
setUnlessNull(props, Environment.TRANSACTION_STRATEGY, JTATransactionFactory.class.getName());
The code I'm using in my web app looks like:
org.hibernate.Transaction tx = null;
try
{
s = HibernateUtils.getSession();
tx = s.beginTransaction();
while (li.hasNext())
tx.commit();
s.close();
}
catch (Exception e)