Java 类org.hibernate.stat.NaturalIdCacheStatistics 实例源码

项目:lams    文件:ConcurrentStatisticsImpl.java   
@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;
}
项目:ignite    文件:HibernateL2CacheSelfTest.java   
/**
 * @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();
    }
}
项目:ignite    文件:HibernateL2CacheSelfTest.java   
/**
 * @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();
    }
}
项目:lemon    文件:StatisticsWrapper.java   
public NaturalIdCacheStatistics getNaturalIdCacheStatistics(
        String regionName) {
    return null;
}
项目:HibernateStatistics    文件:DelegatingStatisticsService.java   
public NaturalIdCacheStatistics getNaturalIdCacheStatistics(String arg0) {
    return delegate.getNaturalIdCacheStatistics( arg0 );
}