@Override public NaturalIdCacheStatistics getNaturalIdCacheStatistics(String regionName) { ConcurrentNaturalIdCacheStatisticsImpl nics = (ConcurrentNaturalIdCacheStatisticsImpl) naturalIdCacheStatistics.get( regionName ); if ( nics == null ) { if ( sessionFactory == null ) { return null; } Region region = sessionFactory.getNaturalIdCacheRegion( regionName ); if ( region == null ) { return null; } nics = new ConcurrentNaturalIdCacheStatisticsImpl( region ); ConcurrentNaturalIdCacheStatisticsImpl previous; if ( ( previous = (ConcurrentNaturalIdCacheStatisticsImpl) naturalIdCacheStatistics.putIfAbsent( regionName, nics ) ) != null ) { nics = previous; } } return nics; }
/** * @param sesFactory Session factory. * @param nameToId Name-ID mapping. * @param absentNames Absent entities' names. */ private void assertNaturalIdCache(SessionFactory sesFactory, Map<String, Integer> nameToId, String... absentNames) { sesFactory.getStatistics().clear(); NaturalIdCacheStatistics stats = sesFactory.getStatistics().getNaturalIdCacheStatistics(NATURAL_ID_REGION); long hitBefore = stats.getHitCount(); long missBefore = stats.getMissCount(); final Session ses = sesFactory.openSession(); try { for (Map.Entry<String, Integer> e : nameToId.entrySet()) assertEquals((int)e.getValue(), ((Entity)ses.bySimpleNaturalId(Entity.class).load(e.getKey())).getId()); for (String name : absentNames) assertNull((ses.bySimpleNaturalId(Entity.class).load(name))); assertEquals(nameToId.size() + hitBefore, stats.getHitCount()); assertEquals(absentNames.length + missBefore, stats.getMissCount()); } finally { ses.close(); } }
public NaturalIdCacheStatistics getNaturalIdCacheStatistics( String regionName) { return null; }
public NaturalIdCacheStatistics getNaturalIdCacheStatistics(String arg0) { return delegate.getNaturalIdCacheStatistics( arg0 ); }