Michael Böckling
Michael Böckling

Reputation: 7942

Hibernate 5 with Spring JTA

I am using:

The official documentation says you only have to set the jtaTransactionManager, and everything works:

    <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
            <property name="dataSource" ref="atomikosDataSource" />
            <property name="jtaTransactionManager" ref="jtaTransactionManager"/>
            [...]
    </bean>

Unfortuntely, the session is not flushed - no writes are taking place. What is the issue?

Upvotes: 4

Views: 4061

Answers (1)

Michael B&#246;ckling
Michael B&#246;ckling

Reputation: 7942

The problem is that Hibernate 5 requires us to set the following property, which Spring doesn't do automatically yet:

<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
    [...]
    <property name="hibernateProperties">
        <props>
            [...]
            <prop key="hibernate.transaction.coordinator_class">jta</prop>
        </props>

This fixed the issue for me.

Upvotes: 6

Related Questions