Search code examples
springhibernatetransactions

Global Transaction Timeout for Spring HibernateTransactionManager


I am using Spring's HibernateTransactionManager to manage my transactions using annotations. It looks like timeout values can be set on annotations, but i dont see how to set them globally for the whole application and then override on the annotation on a need basis.

Here is my configuration

<bean id="txManager"     class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<tx:annotation-driven transaction-manager="txManager"/>

Any ideas? thanks for the help.


Solution

  • HibernateTransactionManager.setDefaultTimeout():

    <bean id="txManager"     class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name = "defaultTimeout" value = "value in milliseconds" />
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>