Recipe

To make it properly work you’ll need to:

1
2
3
hibernate.transaction.coordinator_class=jta
hibernate.transaction.jta.platform=org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform
hibernate.connection.handling_mode=DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT

Example

Here is an example with a Spring XML configuration using multiple DataSources :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!-- ... -->
 
 
<bean id="txManager" class="org.springframework.transaction.jta.WebLogicJtaTransactionManager" />
 
<bean id="sessionFactory1" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource1"/>
    <property name="mappingResources">
        <list>
            <!-- ... -->
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <!-- ... -->
            <prop key="hibernate.transaction.coordinator_class">jta</prop>
            <prop key="hibernate.transaction.jta.platform">org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform</prop>
            <prop key="hibernate.connection.handling_mode">DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT</prop>
        </props>
    </property>
</bean>
 
 
<bean id="sessionFactory2" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource2"/>
    <property name="mappingResources">
        <list>
            <!-- ... -->
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <!-- ... -->
            <prop key="hibernate.transaction.coordinator_class">jta</prop>
            <prop key="hibernate.transaction.jta.platform">org.hibernate.engine.transaction.jta.platform.internal.WeblogicJtaPlatform</prop>
            <prop key="hibernate.connection.handling_mode">DELAYED_ACQUISITION_AND_RELEASE_AFTER_STATEMENT</prop>
        </props>
    </property>
</bean>
 
 
<!-- ... -->
Java Jta Weblogic Hibernate