Example usage for org.hibernate.engine.spi SessionFactoryImplementor getStatistics

List of usage examples for org.hibernate.engine.spi SessionFactoryImplementor getStatistics

Introduction

In this page you can find the example usage for org.hibernate.engine.spi SessionFactoryImplementor getStatistics.

Prototype

@Override
    StatisticsImplementor getStatistics();

Source Link

Usage

From source file:org.infinispan.test.hibernate.cache.commons.functional.JndiRegionFactoryTest.java

License:LGPL

private void addEntityCheckCache(SessionFactoryImplementor sessionFactory) throws Exception {
    Item item = new Item("chris", "Chris's Item");
    withTxSession(s -> s.persist(item));

    withTxSession(s -> {//from   w  ww  .  java2  s  .  c o  m
        Item found = s.load(Item.class, item.getId());
        Statistics stats = sessionFactory.getStatistics();
        log.info(stats.toString());
        assertEquals(item.getDescription(), found.getDescription());
        assertEquals(0, stats.getSecondLevelCacheMissCount());
        assertEquals(1, stats.getSecondLevelCacheHitCount());
        s.delete(found);
    });
}