NHibernate Cached Query
I want to have this cached query in NHibernate:
Configuration configurationEntry = session.CreateQuery("from Configuration configurationEntry where configurationEntry.Name = 'DefaultVendorId'").SetCacheable(true).UniqueResult<Configuration>();
I have
<property name="cache.use_query_cache">true</property>
in the NHibernate configuration file.
However, when I run the NHibernate profiler I see that NHibernate executes the query multiple times .. I obviously want the query executed only o开发者_JAVA百科nce and the result cached. Any ideas ?
Regards, MadSeb
I hope its the same as in Java Hibernate....you have to add a linkage to your cache provider...because Hibernates provides none...
This is part of my Java-Hibernate configuration that links cache provider.
<prop key="hibernate.cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheRegionFactory</prop>
<prop key="hibernate.cache.region.factory_class">net.sf.ehcache.hibernate.EhCacheRegionFactory</prop>
精彩评论