Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
[b]Hibernate version:3.2
[b]Mapping documents:<mapping resource="hib/Testtab.hbm.xml" />
[b]Code between sessionFactory.openSession() and session.close():Auto generated using Myeclipse.
Please can somebody tell me how to fetch the second level cache hits and second level cache miss counts. I always get the count as zero for both.
In my stack trace it says that second level cache enabled and also it gives me the second level cache put count.
that part of code is:
Session ss=getSession();
Query query = ss.createQuery("from Testtab");
Testtab tab=new Testtab();
tab.setId(new Long(4));
tab.setName("four");
ss.saveOrUpdate(tab);
List list= query.list();
Statistics stats = sessionFactory.getStatistics();
stats.setStatisticsEnabled(true);
SecondLevelCacheStatistics cacheStats = stats.getSecondLevelCacheStatistics("hib.Testtab");
ss=getSession();
query=ss.createQuery("from Testtab");
query.list();
ss.close();
ss=getSession();
query=ss.createQuery("from Testtab");
query.list();
ss.close();
Important Stack Trace lines::::
INFO Second-level cache: enabled
DEBUG adding entity to second-level cache: [hib.Testtab#1]
DEBUG hib.TesttabCache: MemoryStore miss for hib.Testtab#1
DEBUG hib.Testtab cache - Miss
DEBUG adding entity to second-level cache: [hib.Testtab#2]
DEBUG hib.TesttabCache: MemoryStore miss for hib.Testtab#2
DEBUG hib.Testtab cache - Miss
DEBUG adding entity to second-level cache: [hib.Testtab#3]
DEBUG hib.TesttabCache: MemoryStore miss for hib.Testtab#3
DEBUG hib.Testtab cache - Miss
DEBUG adding entity to second-level cache: [hib.Testtab#4]
DEBUG hib.TesttabCache: MemoryStore miss for hib.Testtab#4
DEBUG hib.Testtab cache - Miss
DEBUG aggressively releasing JDBC connection
DEBUG releasing JDBC connection