Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The biggest added value (omitting the fact that you can use Hibernate and two databases) is Hibernate's Current Session context management with JTA. You do not have to take care about opening nor closing Session as Hibernate will automatically bind them to the JTA transaction's lifecycle. You just have to make sure JTA transactions are properly started and ended.

...

You have to tell Hibernate where to get the BTM datasource via JNDI. Add a connection.datasource property and set its value to the JNDI location of your datasource:

...

Current session context

You have to set current_session_context_class to jta.

Code Block
xml
xml
<property name="current_session_context_class">jta</property>

Transaction factory class

You have to set transaction.factory_class to org.hibernate.transaction.JTATransactionFactory.

Note
titleJPA / EJB3 API

When you use Hibernate via the JPA / EJB3 API (also known as Hibernate EntityManager) you should not set the transaction.factory_class property as the Ejb3Configuration class will configure a special one which is JTA compatible if you configure your PersistenceUnit's transaction type to JTA.

...

Transaction manager lookup class

You have to set transaction.manager_lookup_class to an implementation of TransactionManagerLookup. Hibernate ships with one that can lookup BTM since version 3.3.

...

Note
titleHibernate connection release mode

There currently is a bug in BTM's connection pool that impacts all versions up to and including 1.3.2. You must set connection.release_mode to after_statement to workaround the bug (see Hibernate's documentation). If you don't, you might end up seeing BTM throwing exceptions and leaking connections.

This is bug BTM-33 which has been fixed in BTM 1.3.3.

...