Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Integrating BTM with Hibernate

Hibernate can be integrated straight with any JTA transaction manager.

The biggest added value (omitting the fact that you can use Hibernate and two databases) is Hibernate's Current Session context management. 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.

Hibernate Session factories

You need to configure exactly one SessionFactory per database.

You have to tell Hibernate to get the BTM datasource via JNDI.

You have to set current_session_context_class to jta. (see http://www.hibernate.org/hib_docs/reference/en/html/session-configuration.html#configuration-misc-properties)

You have to set transaction.factory_class to org.hibernate.transaction.JTATransactionFactory (see http://www.hibernate.org/hib_docs/reference/en/html/session-configuration.html#configuration-transaction-properties)

You have to set transaction.manager_lookup_class to an implementation of TransactionManagerLookup that you have to create yourself.

Here is what the hibernate.cfg.xml file will look like:

  • No labels