How to set the timeout on a NHibernate transaction

孤街醉人 提交于 2019-12-22 06:48:32

问题


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.


回答1:


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>


来源:https://stackoverflow.com/questions/14709978/how-to-set-the-timeout-on-a-nhibernate-transaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!