Search in sources :

Example 1 with CacheDataDescriptionImpl

use of org.hibernate.cache.internal.CacheDataDescriptionImpl in project hibernate-orm by hibernate.

the class CacheImpl method determineNaturalIdRegionAccessStrategy.

@Override
public NaturalIdRegionAccessStrategy determineNaturalIdRegionAccessStrategy(PersistentClass model) {
    NaturalIdRegionAccessStrategy naturalIdAccessStrategy = null;
    if (model.hasNaturalId() && model.getNaturalIdCacheRegionName() != null) {
        final String naturalIdCacheRegionName = cacheRegionPrefix + model.getNaturalIdCacheRegionName();
        naturalIdAccessStrategy = naturalIdRegionAccessStrategyMap.get(naturalIdCacheRegionName);
        if (naturalIdAccessStrategy == null && settings.isSecondLevelCacheEnabled()) {
            final CacheDataDescriptionImpl cacheDataDescription = CacheDataDescriptionImpl.decode(model);
            NaturalIdRegion naturalIdRegion = null;
            try {
                naturalIdRegion = regionFactory.buildNaturalIdRegion(naturalIdCacheRegionName, sessionFactory.getProperties(), cacheDataDescription);
            } catch (UnsupportedOperationException e) {
                LOG.warnf("Shared cache region factory [%s] does not support natural id caching; " + "shared NaturalId caching will be disabled for not be enabled for %s", regionFactory.getClass().getName(), model.getEntityName());
            }
            if (naturalIdRegion != null) {
                naturalIdAccessStrategy = naturalIdRegion.buildAccessStrategy(regionFactory.getDefaultAccessType());
                naturalIdRegionAccessStrategyMap.put(naturalIdCacheRegionName, naturalIdAccessStrategy);
            }
        }
    }
    return naturalIdAccessStrategy;
}
Also used : NaturalIdRegion(org.hibernate.cache.spi.NaturalIdRegion) NaturalIdRegionAccessStrategy(org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy) CacheDataDescriptionImpl(org.hibernate.cache.internal.CacheDataDescriptionImpl)

Aggregations

CacheDataDescriptionImpl (org.hibernate.cache.internal.CacheDataDescriptionImpl)1 NaturalIdRegion (org.hibernate.cache.spi.NaturalIdRegion)1 NaturalIdRegionAccessStrategy (org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy)1