Using jmx, you can access hibernation statistics + ehcache statistics, etc. EhcacheHibernateMBean is the main interface that provides the whole API through jmx. It basically extends two interfaces - EhcacheStats and HibernateStats. And as the name suggests, EhcacheStats contains methods related to Ehcache and HibernateStats related to Hibernate. You can see that cache hit / miss / bet changes the values ββof configuration items dynamically - for example, maxElementInMemory, TTI, TTL, enable / disable statistics collection, etc. And much more. This can be achieved in your application by overriding the buildSessionFactory () method on LocalSessionFactoryBean, adding tc.active as the "true" System property when the second level cache is enabled in the Hibernate configuration
@Override protected SessionFactory buildSessionFactory() throws Exception { Properties properties = this.getHibernateProperties(); String secondLevelCache = (String) properties .get("hibernate.cache.use_second_level_cache"); if (secondLevelCache.equals("true")) { System.setProperty("tc.active", "true"); } return super.buildSessionFactory(); }
No, when you access your application through JMX, go to the Mbeans tab, on the left go to net.sf.ehcache.hibernate -> net.sf.ehcache.Cachemanager @ ..
Under this, go to the attributes. Click on the attributes and on the right hand side, check RegionCacheAttriutes.

Note : the view has changed using JDK1.7. After logging in to the JMX console, go to net.sf.ehcache.hibernate under the Mbeans tab. Click on CacheRegionStats. By clicking on it, the screen on the right will open. Double click on the top and it will display the table navigation as shown below. You will need to navigate the table navigation to find the amount of the object you are interested in.
vsingh
source share