NHibernate QueryOver 缓存问题
我正在开发一个 Windows 窗体智能客户端,它使用 Fluent Nhibernate 1.1 和 NHibernate 3.0 来实现持久性。 由于遗留代码,我别无选择,只能创建一个处理所有客户端级别 CRUD 操作的单个会话。 这往往会使 Nhibernate 会话处于陈旧状态。因此,我决定使用 QueryOver 来消除这个过时的数据问题,因为我的印象是查询结果没有被缓存。 这似乎并没有发生,因为从 NHibernate 返回的结果似乎被缓存了。
我的问题是 QueryOver 的默认实现在返回结果时是否使用某种缓存?
I am developing a windows forms smart client that uses Fluent Nhibernate 1.1 and NHibernate 3.0 for persistence.
Due to legacy code I have had no option but to create a single session that handles all client level CRUD operations.
This tends to leave the Nhibernate session in a stale state. 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.
This doesn’t seem to be the happening as the results returned from NHibernate seem to be cached.
My question is does the default implementation of QueryOver use some sort of caching when the results are returned?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
NHibernate 使用身份映射,它保证无论您如何从数据库获取实体,您总是会获得同一行的相同对象(即在会话内)。
对 winforms 应用程序使用单个会话是一个错误;您看到的问题只是冰山一角。
为了在 winforms 应用程序中更好地处理会话,请检查 Effectus。
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).
Using a single session for a winforms app is a mistake; the issue you're seeing is just the tip of the iceberg.
For better session handling in winforms apps, check Effectus.