In our application configuration, we've got NHibernate configured with both second level and query caches enabled with the SysCacheProvider, configured Fluently...
.Cache(x => x.UseQueryCache().ProviderClass<SysCacheProvider>().UseSecondLevelCache())
We have an entity called Lookup that is marked with Cache.ReadOnly() in its mapping file, and we fetch it using CreateCriteria with SetCacheable(true).SetCacheMode(CacheMode.Normal).
The problem is that the second level cache doesn't seem to be used. Using NHProf, we can see that the first query to fetch the Lookup (by a unique string ID) is correctly cached, but on every call NHibernate then goes to the database to fetch the row by the cached sql ID, rather than using the second level cache.
I've done everything in this blog but to no avail.
Is there something else I need to do, or are there any pitfalls that can mean that entities don't get added to the second level cache?