HHH-10286 SessionFactoryImpl doesn't cache and reuse existing collection cache region access strategies
This commit is contained in:
parent
5cc2175033
commit
828a83dcbf
|
@ -388,22 +388,11 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
Map<String,CollectionMetadata> tmpCollectionMetadata = new HashMap<String,CollectionMetadata>();
|
Map<String,CollectionMetadata> tmpCollectionMetadata = new HashMap<String,CollectionMetadata>();
|
||||||
for ( final Collection model : metadata.getCollectionBindings() ) {
|
for ( final Collection model : metadata.getCollectionBindings() ) {
|
||||||
final String cacheRegionName = cacheRegionPrefix + model.getCacheRegionName();
|
final String cacheRegionName = cacheRegionPrefix + model.getCacheRegionName();
|
||||||
final AccessType accessType = AccessType.fromExternalName( model.getCacheConcurrencyStrategy() );
|
final CollectionRegionAccessStrategy accessStrategy = determineCollectionRegionAccessStrategy(
|
||||||
final CollectionRegionAccessStrategy accessStrategy;
|
regionFactory,
|
||||||
if ( accessType != null && settings.isSecondLevelCacheEnabled() ) {
|
cacheAccessStrategiesMap,
|
||||||
LOG.tracev( "Building shared cache region for collection data [{0}]", model.getRole() );
|
model,
|
||||||
CollectionRegion collectionRegion = regionFactory.buildCollectionRegion(
|
cacheRegionName);
|
||||||
cacheRegionName,
|
|
||||||
properties,
|
|
||||||
CacheDataDescriptionImpl.decode( model )
|
|
||||||
);
|
|
||||||
accessStrategy = collectionRegion.buildAccessStrategy( accessType );
|
|
||||||
cacheAccessStrategiesMap.put( cacheRegionName, accessStrategy );
|
|
||||||
cacheAccess.addCacheRegion( cacheRegionName, collectionRegion );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
accessStrategy = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final CollectionPersister persister = persisterFactory.createCollectionPersister(
|
final CollectionPersister persister = persisterFactory.createCollectionPersister(
|
||||||
model,
|
model,
|
||||||
|
@ -640,6 +629,22 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||||
return accessStrategy;
|
return accessStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private CollectionRegionAccessStrategy determineCollectionRegionAccessStrategy(final RegionFactory regionFactory, Map cacheAccessStrategiesMap, final Collection model,
|
||||||
|
final String cacheRegionName) {
|
||||||
|
CollectionRegionAccessStrategy accessStrategy = (CollectionRegionAccessStrategy) cacheAccessStrategiesMap.get(cacheRegionName);
|
||||||
|
if (accessStrategy == null && settings.isSecondLevelCacheEnabled()) {
|
||||||
|
final AccessType accessType = AccessType.fromExternalName(model.getCacheConcurrencyStrategy());
|
||||||
|
if (accessType != null) {
|
||||||
|
LOG.tracev("Building shared cache region for collection data [{0}]", model.getRole());
|
||||||
|
CollectionRegion collectionRegion = regionFactory.buildCollectionRegion(cacheRegionName, properties, CacheDataDescriptionImpl.decode(model));
|
||||||
|
accessStrategy = collectionRegion.buildAccessStrategy(accessType);
|
||||||
|
cacheAccessStrategiesMap.put(cacheRegionName, accessStrategy);
|
||||||
|
cacheAccess.addCacheRegion(cacheRegionName, collectionRegion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return accessStrategy;
|
||||||
|
}
|
||||||
|
|
||||||
private JdbcConnectionAccess buildLocalConnectionAccess() {
|
private JdbcConnectionAccess buildLocalConnectionAccess() {
|
||||||
return new JdbcConnectionAccess() {
|
return new JdbcConnectionAccess() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue