Hibernate second level cache - print result
I defined a second level cache in my application using @Cache annotation I am using findById query, as the following: long id = 4; Company cmp = companyDAO.findById(id); Where Company is the object that I get from the DB. How can I check if the Company object came from the DB or from the cache? Try HitCount and/or MissCount API. Something like this..... int oldMissCount = sessionFactory.getStatistics().getSecondLevelCacheStatistics(rName).getMissCount(); int oldHitCount = sessionFactory.getStatistics().getSecondLevelCacheStatistics(rName).getHitCount(); long id = 4; Company cmp = companyDAO