Search in sources :

Example 1 with CacheImplementor

use of org.hibernate.engine.spi.CacheImplementor in project hibernate-orm by hibernate.

the class RegionNameTest method testLegacyCacheSpi.

@Test
public void testLegacyCacheSpi() {
    // these need to be the prefixed name
    final String regionName = cachePrefix + '.' + localName;
    final CacheImplementor cache = sessionFactory().getCache();
    // just like stats, the cache for queries cannot be accessed second level cache regions map
    assertEquals(2, cache.getSecondLevelCacheRegionNames().length);
    boolean foundRegion = false;
    for (String name : cache.getSecondLevelCacheRegionNames()) {
        if (EqualsHelper.areEqual(name, regionName)) {
            foundRegion = true;
            break;
        }
    }
    if (!foundRegion) {
        fail("Could not find region [" + regionName + "] in reported list of region names");
    }
    final NavigableRole personEntityName = new NavigableRole(Person.class.getName());
    final NavigableRole nickNamesRole = personEntityName.append("nickNames");
    assert cache.getEntityRegionAccess(personEntityName) != null;
    assert cache.getNaturalIdCacheRegionAccessStrategy(personEntityName) != null;
    assert cache.getCollectionRegionAccess(nickNamesRole) != null;
}
Also used : NavigableRole(org.hibernate.metamodel.model.domain.NavigableRole) CacheImplementor(org.hibernate.engine.spi.CacheImplementor) Test(org.junit.Test)

Aggregations

CacheImplementor (org.hibernate.engine.spi.CacheImplementor)1 NavigableRole (org.hibernate.metamodel.model.domain.NavigableRole)1 Test (org.junit.Test)1