-
You can enable Hibernate statistics generation be setting
hibernate.generate_statisticsproperty totrue. Then you can monitor cache hit/miss count viaSessionFactory.getStatistics().Also, when SQL logging is enabled you can analyze cache behaviour by presence or absense of particular SQL queries.
-
It depends on many factors. See 21.2. The Second Level Cache and 21.4. The Query Cache
-
It depends on cache provider and its configuration. For example, EhCache can be configured to overflow to disk.
-
SessionFactory.getStatistics().getSecondLevelCacheStatistics()provides this information.