开发者

NHibernate Cached Query

开发者 https://www.devze.com 2023-01-27 09:35 出处:网络
I want to have this cached query in NHibernate: Configuration configurationEntry = session.CreateQuery(\"from Configuration configurationEntry where configurationEntry.Name = \'DefaultVendorId\'\").S

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号