Note that there are some explanatory texts on larger screens.

plurals
  1. POproblem in determining whether second level cache is working in hibernate
    primarykey
    data
    text
    <p>I am trying to use ehcache in my project.. i have specified the following properties in hibernate config file -<p></p> <blockquote> <p>config.setProperty("hibernate.cache.provider_class","org.hibernate.cache.EhCacheProvider"); config.setProperty("hibernate.cache.provider_configuration_file_resource_path","ehcache.xml"); config.setProperty("hibernate.cache.use_second_level_cache","true"); config.setProperty("hibernate.cache.use_query_cache","true");</p> </blockquote> <p><p> Now i am still not sure whether the results are coming from DB or the cache..</p> <p>I looked around and found - <a href="https://stackoverflow.com/questions/3156133/hibernate-second-level-cache-print-result">Hibernate second level cache - print result</a> where the person is suggesting HitCount/Misscount API's<p> However when i tried using it the hitcount and miss count is always returned 0... here's my code<p></p> <blockquote> <p>String rName = "org.hibernate.cache.UpdateTimestampsCache"; Statistics stat = HibernateHelper.getInstance().getFactory().getStatistics(); long oldMissCount = stat.getSecondLevelCacheStatistics(rName).getMissCount(); long oldHitCount = stat.getSecondLevelCacheStatistics(rName).getHitCount(); UserDAO user = new UserDAO(); user.read(new Long(1)); long newMissCount = stat.getSecondLevelCacheStatistics(rName).getMissCount(); long newHitCount = stat.getSecondLevelCacheStatistics(rName).getHitCount();</p> <p>if(oldHitCount+1 == newHitCount &amp;&amp; oldMissCount+1 == newMissCount) { System.out.println("came from DB"); } else if(oldHitCount+1 == newHitCount &amp;&amp; oldMissCount == newMissCount) {<br> System.out.println("came from cache"); }</p> </blockquote> <p><p> Please let me know if i am using it wrong.. and what should be the rName(region Name) in this case..</p> <p>Is there any other way of determining whether the second level cache is working ??</p> <p>Thanks </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload