如何在NHibernate事务中设置超时 [英] How to set the timeout on a NHibernate transaction
问题描述
为了让所有事情在同一个事务中工作,我正在使用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屋!