Assuming that you're using EHCache for 2nd level caching, Hibernate does not provide an standard way to get hold of the underlying cache provider, and so you cannot get hold of the Infinispan CacheManager. I can assure you (I wrote the Infinispan 2LC code ) that a only a single cache manager is used for maintaining the Hibernate 2LC.
Is this still true? I see in other posts one isn't supposed to fiddle with the CacheManager, but I see valid use cases for getting information about individual cached ids.
When determining the health of the 2LC for testing purposes, it is useful to be able to look at individual cache entries. For example, I was looping through the cache.getKeys() with EhCache:
CacheKey cacheKey = (CacheKey) key;
Element element = cache.getQuiet(key);
// fields like this are useful to print for debugging
Nevermind. All this is available from the hibernate l2 stats:
Statistics statistics = entityManager.getSession().getSessionFactory().getStatistics();
SecondLevelCacheStatistics l2cacheStats = statistics.getSecondLevelCacheStatistics(cacheName);