0

我们在 Web 应用程序中使用 NHibernate 和流畅的配置。

我们有一个配置数据库和多个保存客户数据的不同数据库。

对于每个数据库,我们在第一次使用时都会进行流畅的配置和 SessionFactory。

我们通过调用它的 OpenSession 方法来获取会话,并在我们处理完它时释放它。

但是,有时我们会收到一条错误消息,表明当我们尝试读取时 ADO 数据读取器仍然处于活动状态。表明 NHibernate 正在尝试(重新)使用相同的连接,这是我们试图避免的。

我们如何确保我们的数据库请求由连接以原子方式处理。(其他请求不得重复使用)

我想重新创建 SessionFactory 可能会起作用,但这似乎很昂贵

4

1 回答 1

2

A few questions

  • You are using different connection strings so it is separate application pools?
  • What is the exact error message you get?

I can't see how this should be nHibernate's fault. If the problem is easily reproduceable then maybe you can try to:

  • Trace from the database side to see whats going on (especially sp_resetconnection)
  • Disable connection pooling to see if that makes a difference
于 2012-02-06T16:02:54.740 回答