In my grails application, I want to display all the current entries of the second-level cache from all regions.
My code is as following :
def getCacheStats() {
StatisticsImpl stats = sessionFactory.statistics
for (regionName in stats.secondLevelCacheRegionNames) {
log.debug stats.getSecondLevelCacheStatistics(regionName).entries
}
}
However everything works fine as long as the region name is not org.hibernate.cache.StandardQueryCache
(region used for Query Cache). In that case, an exception is thrown :
java.lang.ClassCastException: org.hibernate.cache.QueryKey cannot be cast to org.hibernate.cache.CacheKey
Having googling around, I didn't find any clues about how to display the list of entries of the cached query result sets associated with regions StandardQueryCache
and UpdateTimestampsCache
.
Could you please help me find a solution for this?