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开发者_Python百科 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?
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.
精彩评论