According to this documentation, when using Infinispan with Hibernate it is possible to define multiple cache regions and configure them individually. I'm using WildFly 8.0, which uses Infinispan as a default 2LC provider for Hibernate. So here's my standalone.xml configuration for hibernate cache container:
<cache-container name="hibernate" default-cache="local-query" module="org.hibernate">
<local-cache name="entity">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="local-query">
<transaction mode="NONE"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
<local-cache name="timestamps">
<transaction mode="NONE"/>
<eviction strategy="NONE"/>
</local-cache>
</cache-container>
So, the max idle expiration time is set to 100 seconds. This is how I tell Hibernate to cache query:
slotQuery.setHint("org.hibernate.cacheable", true)
.setHint("org.hibernate.cacheRegion", "myRegionName")
.getResultList();
Everything is working perfeclty, the queries are being cached for 100 seconds. But when I'm trying to configure a separate cache region for the query in persistence.xml:
<property name="hibernate.cache.use_second_level_cache" value="true"/>
<property name="hibernate.cache.use_query_cache" value="true"/>
<property name="hibernate.cache.infinispan.myRegionName.expiration.max_idle" value="5000"/>
settings are not being overriden, and the query is cached for 100 seconds. What am I missing here?