I have a piece of code that, in essense, does:

Session.CreateCriteria(typeof (TDomainObject)).SetCacheable
(true).List<TDomainObject>();

Where Session is NH session, of course. The second level cache is
configured and turned on. hibernate.cache.use_query_cache is set to
true. The TDomainObject has caching enabled in the mapping file. When
I run the program with log level cranked up to DEBUG, I can see NH
putting data into the cache, and I can see the objects in my second
level cache (to be specific, I am using NCache -- an out of proc,
cluster-level cache). The problem is that when the program is run
repeatedly, it always hits the database, regardless of whether the
results are already in the cache or not. If I run Session.Load(typeof
(TDomainObject), 1) when there's something in the cache -- it works as
expected -- i.e. NH checks the cache, and returns the object out of
memory.

Am I missing something trivial, or is the scenario above just not
supported? What would I need to do to make NH hit the cache? Create an
explicit query in xml, enable caching for it, and use it instead
of .List()?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to