Dear Community!
I'm using WebSphere 6.0.2.17 with a DB2 8.1 and Hibernate 3.2.4.SP1. My application which runs in an XA environment and simply receives JMS messages and updates an Entity in the DB. All happens in one transaction in an SSB, running Bean managed transaction demarcation.
The Hibernate config is using the following settings for the Session:
Code:
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JTATransactionFactory
</property>
<property name="hibernate.transaction.manager_lookup_class">
org.hibernate.transaction.WebSphereExtendedJTATransactionLookup
</property>
I noticed after some problems with transactions that the current Hibernate implementation of the class
org.hibernate.transaction.WebSphereExtendedJTATransactionLookup implements the
javax.transaction.TransactionManager and
javax.transaction.Transaction interfaces with its subclasses
TransactionManagerAdapter and
TransactionAdapter. These implementations - which are used by Hibernate for transaction demarcation - are throwing
UnsupportedOperationException in every method of the interfaces (begin, commit, rollback etc.).
Is there actually a special reason for this? Since it draws all transaction management by the Hibernate transaction abstraction useless. All other Lookup-Classes (JBoss, WebLogic) do not do that.
Since I know that IBM uses a proprietary way to get the TransactionManager, I implemented my own Lookup-Class which is quite simple:
Code:
package some.where.over.the.rainbow;
import java.util.Properties;
import javax.transaction.TransactionManager;
import org.hibernate.HibernateException;
import org.hibernate.transaction.TransactionManagerLookup;
public class CustomizedWASJTATransactionLookup implements TransactionManagerLookup {
public TransactionManager getTransactionManager(Properties props)
throws HibernateException {
//This actually gets the WAS TransactionManager
return com.ibm.ws.Transaction.TransactionManagerFactory.getTransactionManager();
}
public String getUserTransactionName() {
return "java:comp/UserTransaction";
}
}
I did some tests for different cases, in CMT and BMT environments. I used the Hibernate abstraction API like:
Code:
Transaction tx = hibernateSession.beginTransaction();
[... DO SOME STUFF ...]
tx.commit() || tx.rollback();
Everything worked fine.
Now what I would like to know is (just to be sure), does anybody see any problems with this approach?
Any comments appreciated! Thank you.
Kind Regards.