As I already said (sorry if that was not clear), the entities are
cached. This particular select returns about 11K rows, and after
running the program I see 11K objects in my NCache cache. What I don't
see (in the logs, at least) is Nhibernate trying to use those cached
objects -- it just hits the database again.

On Jun 2, 9:22 am, Jason Meckley <[email protected]> wrote:
> a query only caches the entity ids. The entity itself needs to be
> cached.
>
> the mapping would look like this
> <class name="Foo" cachable="true" cache-region="the.cache.key">
> ....
> </class>
>
> your code would be the same.
> Session.CreateCriteria<Foo>().SetCacheable(true).List<Foo>();
>
> On Jun 2, 9:00 am, Fabio Maulo <[email protected]> wrote:
>
> >http://ayende.com/Blog/archive/2009/04/24/nhibernate-2nd-level-cache....
> > 2009/6/2 Max Badrak <[email protected]>
>
> > > 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()?
>
> > --
> > Fabio Maulo
--~--~---------~--~----~------------~-------~--~----~
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