Where and how to check that hibernate cache really works

  1. You can enable Hibernate statistics generation be setting hibernate.generate_statistics property to true. Then you can monitor cache hit/miss count via SessionFactory.getStatistics().

    Also, when SQL logging is enabled you can analyze cache behaviour by presence or absense of particular SQL queries.

  2. It depends on many factors. See 21.2. The Second Level Cache and 21.4. The Query Cache

  3. It depends on cache provider and its configuration. For example, EhCache can be configured to overflow to disk.

  4. SessionFactory.getStatistics().getSecondLevelCacheStatistics() provides this information.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)