The doc comment to Statistics#getSecondLevelCacheRegionNames()
says that for backwards compatibility, this method returns just the names of regions storing domain data, not query result cache regions.
Maybe I’m missing something, but using this method returns the cache names for my query caches as well. I have an Ehcache 3
which I configure like that:
<cache-template name="small-cache">
<expiry><ttl>3600</ttl></expiry>
<resources>
<heap>10</heap>
<offheap unit="MB">1</offheap>
</resources>
</cache-template>
<cache alias="email-status-cache" uses-template="small-cache"/>
<cache alias="email-status-query-cache" uses-template="small-cache"/>
Well, the Ehcache configuration says nothing about the use case of the configured caches. So I assume that Hibernate
will derive the use case from the placing of the case specific annotations. For classic entity caches eg. @org.hibernate.annotations.Cache(region = "email-status-cache", usage = CacheConcurrencyStrategy.READ_ONLY)
.
And for query caches:
@QueryHints(value = {
@QueryHint(name = HibernateHints.HINT_CACHEABLE, value = "true"),
@QueryHint(name = HibernateHints.HINT_CACHE_REGION, value = "email-status-query-cache")
}, forCounting = false)
Surprisingly, when calling Statistics#getSecondLevelCacheRegionNames()
, both cache region names get delivered, meaning the query cache region name will be returned as well.
Is this a bug, a feature or am I just missing anything? Can I rely on this beahvior in future as well?
Many thanks for any information