...
Hibernate can be integrated straight with any JTA transaction manager. These instructions have been verified against BTM 2.01.1 and Hibernate 3.6.3.0Final.SP1.
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.
...
| Code Block | ||
|---|---|---|
| ||
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.sourceforge.netorg/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">jdbc/testDS1</property>
<property name="connection.release_mode">after_statement</property>
<property name="current_session_context_class">jta</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.BTMTransactionManagerLookup</property>
<property name="dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<mapping resource="bitronix/examples/hibernate/entities/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
|
...
| Code Block | ||
|---|---|---|
| ||
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.sourceforge.netorg/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">jdbc/testDS2</property>
<property name="connection.release_mode">after_statement</property>
<property name="current_session_context_class">jta</property>
<property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="transaction.manager_lookup_class">org.hibernate.transaction.BTMTransactionManagerLookup</property>
<property name="dialect">org.hibernate.dialect.DerbyDialect</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<mapping resource="bitronix/examples/hibernate/entities/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
|
...