use of org.hibernate.cache.cfg.spi.NaturalIdDataCachingConfig in project hibernate-orm by hibernate.
the class EnabledCaching method prime.
@Override
public void prime(Set<DomainDataRegionConfig> cacheRegionConfigs) {
for (DomainDataRegionConfig regionConfig : cacheRegionConfigs) {
final DomainDataRegion region = getRegionFactory().buildDomainDataRegion(regionConfig, this);
regionsByName.put(region.getName(), region);
if (!StringTypeDescriptor.INSTANCE.areEqual(region.getName(), regionConfig.getRegionName())) {
throw new HibernateException(String.format(Locale.ROOT, "Region [%s] returned from RegionFactory [%s] was named differently than requested name. Expecting `%s`, but found `%s`", region, getRegionFactory().getClass().getName(), regionConfig.getRegionName(), region.getName()));
}
for (EntityDataCachingConfig entityAccessConfig : regionConfig.getEntityCaching()) {
final EntityDataAccess entityDataAccess = entityAccessMap.put(entityAccessConfig.getNavigableRole(), region.getEntityDataAccess(entityAccessConfig.getNavigableRole()));
legacySecondLevelCacheNames.add(StringHelper.qualifyConditionally(getSessionFactory().getSessionFactoryOptions().getCacheRegionPrefix(), region.getName()));
}
if (regionConfig.getNaturalIdCaching().isEmpty()) {
legacyNaturalIdAccessesForRegion.put(region.getName(), Collections.emptySet());
} else {
final HashSet<NaturalIdDataAccess> accesses = new HashSet<>();
for (NaturalIdDataCachingConfig naturalIdAccessConfig : regionConfig.getNaturalIdCaching()) {
final NaturalIdDataAccess naturalIdDataAccess = naturalIdAccessMap.put(naturalIdAccessConfig.getNavigableRole(), region.getNaturalIdDataAccess(naturalIdAccessConfig.getNavigableRole()));
accesses.add(naturalIdDataAccess);
}
legacyNaturalIdAccessesForRegion.put(region.getName(), accesses);
}
for (CollectionDataCachingConfig collectionAccessConfig : regionConfig.getCollectionCaching()) {
final CollectionDataAccess collectionDataAccess = collectionAccessMap.put(collectionAccessConfig.getNavigableRole(), region.getCollectionDataAccess(collectionAccessConfig.getNavigableRole()));
legacySecondLevelCacheNames.add(StringHelper.qualifyConditionally(getSessionFactory().getSessionFactoryOptions().getCacheRegionPrefix(), region.getName()));
}
}
}
Aggregations