如何保持长时间运行NHibernate的会话数据是否一致? [英] How to keep long running NHibernate Session data consistent?

查看:187
本文介绍了如何保持长时间运行NHibernate的会话数据是否一致?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET缓存会话NHibernate的会议。

I have NHibernate sessions cached in the ASP.NET session.

我碰到其中一个用户编辑的对象,因此它在的Isession其一级缓存的情况。另一位用户则编辑同一个对象。

I came across a situation where a user edited an object so it's in their first level cache in the ISession. Another user then edited the same object.

此时用户1仍然可以看到原来的自己编辑的版本,其中为用户2看到物体的正确状态?

At this point User1 still sees their original version of their edits where as User2 sees the correct state of the object?

什么是正确的方式来处理,而无需手动调用session.Refresh(MyObj中)明确为每一个对象所有的时间?

What is the correct way to handle this without manually calling session.Refresh(myObj) explicitly for every single object all the time?

我也有启用2级缓存。对于NHibernate的长会话我应该只是关闭一级缓存完全?

I also have a 2nd level cache enabled. For NHibernate Long Session should I just disable the first level cache entirely?

编辑:添加一些术语,我正在寻找从的 10.4.1。与自动版本本节结束长会议结束与

Adding some more terminology to what I'm looking to achieve from 10.4.1. Long session with automatic versioning the end of this section concludes with

由于ISession的也是(必须的)第一级缓存,并包含所有加载的对象,我们可以propably使用这种策略只对少数请求/响应周期。这的确是推荐的,因为的ISession很快就会出现过时的数据。

As the ISession is also the (mandatory) first-level cache and contains all loaded objects, we can propably use this strategy only for a few request/response cycles. This is indeed recommended, as the ISession will soon also have stale data.

我不知道这是什么样的文档为它都可能再包括立即说,会议将陈旧的数据(这是我所看到的)。有什么解决办法在这里或这种权利是没有的?

I'm not sure what kind of documentation this is for it to include both probably and then immediately say the session will have stale data (which is what I'm seeing). What's the solution to this right here or is there none?

推荐答案

显然,这是NHibernate的一个已知的缺点在我的问题提到的文档越详细。

Apparently this is a known shortcoming of NHibernate as detailed by documentation cited in my question.

这篇关于如何保持长时间运行NHibernate的会话数据是否一致?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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