简体   繁体   English

NHibernate QueryOver缓存问题

[英]NHibernate QueryOver Caching Issue

I am developing a windows forms smart client that uses Fluent Nhibernate 1.1 and NHibernate 3.0 for persistence. 我正在开发使用Fluent Nhibernate 1.1和NHibernate 3.0进行持久化的Windows窗体智能客户端。 Due to legacy code I have had no option but to create a single session that handles all client level CRUD operations. 由于遗留代码,我没有选择,只能创建一个处理所有客户端级别CRUD操作的会话。 This tends to leave the Nhibernate session in a stale state. 这倾向于使Nhibernate会话处于陈旧状态。 So I have made the decision to use QueryOver to eliminate this stale data issue, as I was under the impression that query results were not cached. 所以我决定使用QueryOver来消除这个陈旧的数据问题,因为我认为查询结果没有被缓存。 This doesn't seem to be the happening as the results returned from NHibernate seem to be cached. 这似乎不会发生,因为从NHibernate返回的结果似乎是缓存的。

My question is does the default implementation of QueryOver use some sort of caching when the results are returned? 我的问题是QueryOver的默认实现是否在返回结果时使用某种缓存?

NHibernate uses an identity map, which guarantees that, no matter how you get an entity from the DB, you'll always get the same object for the same row (inside a session, that is). NHibernate使用一个身份映射,该身份映射保证,无论您如何从数据库中获取实体,都将始终为同一行(在会话内)获得相同的对象。

Using a single session for a winforms app is a mistake; 对于winforms应用程序使用单个会话是一个错误; the issue you're seeing is just the tip of the iceberg. 你所看到的问题只是冰山一角。

For better session handling in winforms apps, check Effectus . 要在winforms应用程序中更好地管理会话,请检查Effectus

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM