如何在NHibernate事务中设置超时 [英] How to set the timeout on a NHibernate transaction

查看:1351
本文介绍了如何在NHibernate事务中设置超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在单个事务中完成大量的数据库处理,包括使用NHibernate的一些处理。

为了让所有事情在同一个事务中工作,我正在使用NHibernate的会话启动它,并争取其他工作的命令。

一切都会好,直到我提交。在这个时候,我得到一个事务超时。

如何设置NHibernate事务超时值足够高?

我们使用FluentNHibernate。

解决方案

经过一些试验和大量的错误,我发现这一点:



看来,NHibernate采取TransactionManager.DefaultTimeout值。

它可以通过设置

 < system.transactions> 
< defaultSettings timeout =01:00:00/>

在app / web config中

如果设置为高于TransactionManager.MaximumTimeout的值,则事务超时将默认为该值。
如果您需要更长的时间,可以通过更新.Net框架版本的machine.config来延长这个时间:

 < System.Transactions的> 
< machineSettings maxTimeout =01:00:00/>


I need a lot of DB processing done in a single transaction, including some processing using NHibernate.

To make everything work in the same transaction, I'm using NHibernate's Session to start it, and enlist the the commands for the other work in it.

Everything goes OK until I commit. At that time I get a transaction timeout.

How can I set the NHibernate transaction timeout value sufficiently high?

We use FluentNHibernate.

解决方案

After some trial and lots of error I found this:

It appears that NHibernate takes the "TransactionManager.DefaultTimeout" value.

It can be set via

 <system.transactions>
     <defaultSettings timeout="01:00:00" />
 </system.transactions>

in the app/web config

If it is set to a value higher than TransactionManager.MaximumTimeout the transaction timeout will default to that. If you need longer you can lengthen that time by updating the "machine.config" for your .Net framework version with:

<system.transactions>
    <machineSettings maxTimeout="01:00:00" />
</system.transactions>

这篇关于如何在NHibernate事务中设置超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆