Thanks for the responses.  I have setup caching on the Person entity
yes, I think I was misunderstanding how the query cache works, I was
hoping to avoid a trip to the DB to retrieve the Ids.

I'll have a read about the cache implementation options as well if
HashtableCacheProvider is only for testing use.

Thanks again,
Matt

On Aug 7, 8:43 pm, Jason Meckley <[email protected]> wrote:
> HashtableCacheProvider should only be used for testing. It is not
> production quality code.
> as Jakob noted you need to configure caching on the entities, as well
> as the queries. a query will only cache the id of the entities
> selected. it will then look in the entity cache for entity matching
> that id. if that id doesn't exist it will go to the database.
>
> 2nd level cache is considered advanced use of NH. it is complex by
> design and should only be implemented as a last resort for performance
> gains.
>
> On Aug 7, 10:49 am, Jakob Tikjøb Andersen <[email protected]> wrote:
>
> > Do you have set up caching in your mapping file for the Person mapping like:
>
> > <class name="Person".....>
> >     <cache usage="read-only"/>
> >     ....
> > </class>
>
> > --
> > Jakob Tikjøb Andersen
> > +45 25 277 105
>
> > On Fri, Aug 7, 2009 at 2:11 PM, mattcole <[email protected]> wrote:
>
> > > Hi,
>
> > > I can't seem to get query caching to work for me, or else I'm
> > > misunderstanding how it should work.
>
> > > The following test:
>
> > > [Test]
> > >        public void Test()
> > >        {
> > >            var person = PersonBuilder.New().Build();
> > >            _session.Save(person);
> > >            _session.Flush();
>
> > >            var query = _session.CreateCriteria<Person>()
> > >                .Add(Restrictions.Eq("Id", person.Id))
> > >                .SetCacheable(true);
>
> > >            var listOne = query.List();
> > >            var listTwo = query.List();
> > >        }
>
> > > causes two queries to the db, and in the session factory statistics I
> > > can see that there have been 2 QueryCachePuts and 2 QueryCacheMisses,
> > > and no QueryCacheHits.
>
> > > I would have hoped that the first query would execute, and the second
> > > hit the cache.  Is that correct or am I missing something?
>
> > > My config file has these lines:
>
> > > <property
> > > name="cache.provider_class">NHibernate.Cache.HashtableCacheProvider</
> > > property>
> > >    <property name="cache.use_second_level_cache">true</property>
> > >    <property name="cache.use_query_cache">true</property>
>
> > > Thanks,
> > > Matt
--~--~---------~--~----~------------~-------~--~----~
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