private Set<String> getCacheEntrySet(SecondLevelCacheStatistics slStats) { Set<String> entities = Generics.newHashSet(); /* Liefert z.Zt ClassCastException. * (http://opensource.atlassian.com/projects/hibernate/browse/HHH-2815) */ Map<?,?> entries = slStats.getEntries(); if (slStats != null && entries != null) { for (Iterator<?> iterator = entries.entrySet().iterator(); iterator.hasNext();) { Entry<?,?> entry = (Entry<?,?>) iterator.next(); if (entry.getValue() instanceof CacheEntry) { String clzz = ((CacheEntry)entry.getValue()).getSubclass(); if (clzz != null) { entities.add(clzz); } } } } return entities; }
public Object getChild(Object parent, int index) { if(parent==stats) { switch(index) { case 0: return entities; case 1: return collections; case 2: return queries; case 3: return secondlevelcache; } } else if(parent==entities) { return stats.getEntityStatistics(stats.getEntityNames()[index]); } else if(parent==collections) { return stats.getCollectionStatistics(stats.getCollectionRoleNames()[index]); } else if(parent==queries) { return stats.getQueryStatistics(stats.getQueries()[index]); } else if(parent==secondlevelcache) { return stats.getSecondLevelCacheStatistics( stats.getSecondLevelCacheRegionNames()[index]); } else if(parent instanceof SecondLevelCacheStatistics) { SecondLevelCacheStatistics slcs = (SecondLevelCacheStatistics) parent; return slcs.getEntries(); } return null; }
QueryStatistics queryStats = stats.getQueryStatistics("from Store s"); queryStats.getCacheHitCount(); queryStats.getCacheMissCount(); queryStats.getCachePutCount(); queryStats.getExecutionCount(); queryStats.getExecutionAvgTime(); queryStats.getExecutionMaxTime(); queryStats.getExecutionMinTime(); queryStats.getExecutionRowCount(); SecondLevelCacheStatistics cacheStats = stats.getSecondLevelCacheStatistics("Sale.cache"); cacheStats.getElementCountInMemory(); cacheStats.getElementCountOnDisk(); cacheStats.getEntries(); cacheStats.getHitCount(); cacheStats.getMissCount(); cacheStats.getPutCount(); cacheStats.getSizeInMemory(); CollectionStatistics collectionStats = stats.getCollectionStatistics("Sale.items"); collectionStats.getFetchCount(); collectionStats.getLoadCount(); collectionStats.getRecreateCount(); collectionStats.getRemoveCount(); collectionStats.getUpdateCount();