If you are using spring to manage transactions then you can specify default transaction timeout using
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
<property name="defaultTimeout" value="30" /> <!--30 sec--->
</bean>
or you can override the timeout in the annotation
@Transactional(readOnly = false, timeout=30)
or if you are doing it programatic transactions then you can do
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
transactionManager.setDefaultTimeout(30);
or you can override the timeout for one particular transaction
TransactionTemplate transactionTemplate = new TransactionTemplate();
transactionTemplate.setTimeout(30);
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
<property name="defaultTimeout" value="30" /> <!--30 sec--->
</bean>
or you can override the timeout in the annotation
@Transactional(readOnly = false, timeout=30)
or if you are doing it programatic transactions then you can do
DataSourceTransactionManager transactionManager = new DataSourceTransactionManager(dataSource);
transactionManager.setDefaultTimeout(30);
or you can override the timeout for one particular transaction
TransactionTemplate transactionTemplate = new TransactionTemplate();
transactionTemplate.setTimeout(30);
Comments
Post a Comment