Search code examples
javaxmlhibernateehcachesecond-level-cache

How to config QueryCache in ehcache.xml


From my sql log file, I think the QueryCache's physical properties are configured by the element:

  <defaultCache
                maxElementsInMemory="0"
                eternal="false"
                timeToIdleSeconds="120"
                timeToLiveSeconds="120"
                overflowToDisk="false"
                memoryStoreEvictionPolicy="LRU"
                />

and even I add another element the element below to the ehcache.xml, is seems, from the sql log, that the QueryCache's physical properties are still configured by the element.

  <cache name="org.hibernate.cache.QueryCache"
                maxElementsInMemory="10000"
                eternal="false"
                timeToIdleSeconds="120"
                timeToLiveSeconds="120"
                overflowToDisk="false"
                memoryStoreEvictionPolicy="LRU"
        />

I just want to enable the QueryCache in memory, and meanwhile disable the others (in memory) by default. Maybe the name attribute of element is not correct? I copy it from the book <>. Or, should I use another element other than ? Maybe there is a kinda of element?

Thanks.


Solution

  • Try: name="org.hibernate.cache.StandardQueryCache"