org.hibernate.stat.NaturalIdCacheStatistics Java Examples

The following examples show how to use org.hibernate.stat.NaturalIdCacheStatistics. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HibernateL2CacheSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @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();
    }
}
 
Example #2
Source File: HibernateL2CacheSelfTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/**
 * @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();
    }
}
 
Example #3
Source File: StatisticsWrapper.java    From lemon with Apache License 2.0 4 votes vote down vote up
public NaturalIdCacheStatistics getNaturalIdCacheStatistics(
        String regionName) {
    return null;
}