use of org.hibernate.stat.Statistics in project redisson by redisson.
the class ReadWriteTest method testNaturalId.
@Test
public void testNaturalId() {
Statistics stats = sessionFactory().getStatistics();
Session s = openSession();
s.beginTransaction();
ItemReadWrite item = new ItemReadWrite("data");
item.setNid("123");
s.save(item);
s.flush();
s.getTransaction().commit();
Assert.assertEquals(1, stats.getDomainDataRegionStatistics("item").getPutCount());
Assert.assertEquals(1, stats.getNaturalIdStatistics(ItemReadWrite.class.getName()).getCachePutCount());
s = openSession();
s.beginTransaction();
item = (ItemReadWrite) s.bySimpleNaturalId(ItemReadWrite.class).load("123");
assertThat(item).isNotNull();
s.delete(item);
s.getTransaction().commit();
s.close();
Assert.assertEquals(1, stats.getDomainDataRegionStatistics("item").getHitCount());
Assert.assertEquals(1, stats.getNaturalIdStatistics(ItemReadWrite.class.getName()).getCacheHitCount());
sessionFactory().getStatistics().logSummary();
}
use of org.hibernate.stat.Statistics in project keycloak by keycloak.
the class HibernateStatsReporter method run.
@Override
public void run(KeycloakSession session) {
SessionFactory sessionFactory = ((SessionFactoryImpl) emf);
Statistics stats = sessionFactory.getStatistics();
logStats(stats);
// For now, clear stats after each iteration
stats.clear();
}
Aggregations