In this article:
http://msepc10.scs.ad.cs.cmu.edu/sapphi ... ment_Notes
First approach:
Share the session among clients to have single cache guaranteeing that there is a unique in-memory representation of any domain model object. This approach may not be optimal because a session is not thread-safe. We were planning to ignore this and to add synchronization later. Unfortunately we came across another problem: database access works well for a local client (unit tests). For a remote client, however, the first database access succeeds but later attempts to read from another table fail, NHibernate can't even parse the HQL statement.
The problem was caused by a missing statement in the server object. We only read 2 of the three mapping files.
-----------------------------------------------------------
I want to make use of the caching, which NHibernate session provided already, to cache some common codes, so that every client can just read the code using this session and mostly from the cache. I don't want to create NHibernate session for each client, cause they have to re-load data from database. If I use the same session, I can take adavantage of lazy loading together with caching for the common codes (each code may have 1-many children, I'd like to have lazy loading. And there are lots of codes, I don't want to load them all in one shot. I'd like to make use of cache and lazyloading, and the cache will dump some codes when not using them.)
For upper purpose,cause it's read-only, I think it will be ok even the session is not thread-safe. But I am not sure and I am not sure whether I can do stress test easily. Can you guys confirm it?
For next step, I'd like reuse the session for updating some time. If one admin client come in to modify the common codes, and if he can make use of the same session and the code is cached in the session, he don't need to fetch from the DB again. Why can't NHibernate implement this?