In NHibernate
you can easily benefit from first level cache when using Load
or Get
methods. But what about ICriteria
, HQL
, Linq-to-NHibernate
and QueryOver
? Do they use first level cache too?
Can first level cache be used with ICriteria or other APIs?
745 views Asked by Afshar At
2
They use it for returning entities, but the queries go straight to the db unless you use the second level cache.
Consider this:
Two queries are executed (one for the Get, one for the Query), but both variables contain the same object reference.
Now, if you enable the 2nd level cache, query caching, and specify caching for the query:
Only one query will be executed.