是不是NHibernate的"每个请求&QUOT一次会议;模式有点危险长期Web请求? [英] Isn't NHibernate's "one session per request" pattern a bit dangerous for long web requests?

查看:86
本文介绍了是不是NHibernate的"每个请求&QUOT一次会议;模式有点危险长期Web请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的,我们正在使用NHibernate的会议包装,全部部署在同一请求结束当前Web请求开了会议,并提交所有相关事务工作的公司(我们正在处理一个多数据库环境中,我们创建一个会话的每个数据库)。

In the company I work for, we're using a NHibernate session wrapper that disposes all the sessions opened in the current web request at the end of the same request, and commits all the associated transactions (we're working in a multi-database environment, and we create a session for every database).

另外,我们正在使用的会话包装,会话和交易耦合,我们不能提交事务没有处理的会话。

Also, in the session wrapper we're using, the session and the transactions are coupled, and we can't commit a transaction without disposing its session.

的问题是,有时,一个事务保持打开的所有请求生命和数据库表保持锁定为太时间

The problem is that, sometimes, a transaction stays open for all the request life, and database tables stays locked for much too time.

...是我们失去了一些东西?

... are we missing something?

推荐答案

每个请求的会话只有一个办法做到的会话生命周期管理。这恰好是推荐的策略Web应用程序,但NHibernate的是真的无动于衷,你如何管理你的会话有效期。

Session per request is only one way to do session lifecycle management. It happens to be the recommended strategy for web apps, but NHibernate is really indifferent to how you manage your session lifetime.

您当然可以使用具有或长或短的生活比一个请求的会议。如果你有使用的情况下,将更好地工作,以这种方式,通过各种手段,去了。

You can certainly use sessions that have shorter or longer lives than a single request. If you have use cases that would work better in that way, by all means, go for it.

不要让你的会话的包装把不必要的限制你的适应NHibernate的,以应用程序的需求的能力。

Don't let your session wrapper put unnecessary constraints on your ability to adapt NHibernate to the needs of your application.

这篇关于是不是NHibernate的"每个请求&QUOT一次会议;模式有点危险长期Web请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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