Skip to content

Commit feea196

Browse files
committed
clean up obsolete code in EnabledCaching
1 parent 6d922bf commit feea196

File tree

1 file changed

+13
-39
lines changed

1 file changed

+13
-39
lines changed

hibernate-core/src/main/java/org/hibernate/cache/internal/EnabledCaching.java

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
*/
55
package org.hibernate.cache.internal;
66

7-
import java.util.Collections;
8-
import java.util.HashSet;
9-
import java.util.LinkedHashSet;
107
import java.util.Locale;
118
import java.util.Map;
129
import java.util.Objects;
@@ -71,9 +68,6 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
7168
private final Map<String, QueryResultsCache> namedQueryResultsCacheMap = new ConcurrentHashMap<>();
7269

7370

74-
private final Set<String> legacySecondLevelCacheNames = new LinkedHashSet<>();
75-
private final Map<String,Set<NaturalIdDataAccess>> legacyNaturalIdAccessesForRegion = new ConcurrentHashMap<>();
76-
7771
public EnabledCaching(SessionFactoryImplementor sessionFactory) {
7872
this.sessionFactory = sessionFactory;
7973
final var options = sessionFactory.getSessionFactoryOptions();
@@ -105,7 +99,6 @@ private TimestampsCache buildTimestampsCache(SessionFactoryImplementor sessionFa
10599
DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME,
106100
sessionFactory
107101
);
108-
legacySecondLevelCacheNames.add( timestampsRegion.getName() );
109102
return sessionFactory.getSessionFactoryOptions().getTimestampsCacheFactory()
110103
.buildTimestampsCache( this, timestampsRegion );
111104
}
@@ -134,27 +127,16 @@ public void prime(Set<DomainDataRegionConfig> cacheRegionConfigs) {
134127
for ( var entityAccessConfig : regionConfig.getEntityCaching() ) {
135128
final var navigableRole = entityAccessConfig.getNavigableRole();
136129
entityAccessMap.put( navigableRole, region.getEntityDataAccess( navigableRole ) );
137-
legacySecondLevelCacheNames.add( qualifiedRegionName( region ) );
138130
}
139131

140132

141133
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142134
// Natural-id caching
143135

144-
final var naturalIdCaching = regionConfig.getNaturalIdCaching();
145-
if ( naturalIdCaching.isEmpty() ) {
146-
legacyNaturalIdAccessesForRegion.put( region.getName(), Collections.emptySet() );
147-
}
148-
else {
149-
final Set<NaturalIdDataAccess> accesses = new HashSet<>();
150-
for ( var naturalIdAccessConfig : naturalIdCaching ) {
151-
final var navigableRole = naturalIdAccessConfig.getNavigableRole();
152-
final var naturalIdDataAccess =
153-
naturalIdAccessMap.put( navigableRole,
154-
region.getNaturalIdDataAccess( navigableRole ) );
155-
accesses.add( naturalIdDataAccess );
156-
}
157-
legacyNaturalIdAccessesForRegion.put( region.getName(), accesses );
136+
for ( var naturalIdAccessConfig : regionConfig.getNaturalIdCaching() ) {
137+
final var navigableRole = naturalIdAccessConfig.getNavigableRole();
138+
naturalIdAccessMap.put( navigableRole,
139+
region.getNaturalIdDataAccess( navigableRole ) );
158140
}
159141

160142

@@ -165,7 +147,6 @@ public void prime(Set<DomainDataRegionConfig> cacheRegionConfigs) {
165147
final var navigableRole = collectionAccessConfig.getNavigableRole();
166148
collectionAccessMap.put( navigableRole,
167149
region.getCollectionDataAccess( navigableRole ) );
168-
legacySecondLevelCacheNames.add( qualifiedRegionName( region ) );
169150
}
170151
}
171152

@@ -213,7 +194,6 @@ public Region getRegion(String regionName) {
213194
}
214195

215196

216-
217197
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
218198
// Entity data
219199

@@ -309,7 +289,6 @@ public void evictEntityData() {
309289
}
310290

311291

312-
313292
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
314293
// Natural-id data
315294

@@ -341,7 +320,6 @@ private void evictNaturalIdData(NavigableRole rootEntityRole, NaturalIdDataAcces
341320
}
342321

343322

344-
345323
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
346324
// Collection data
347325

@@ -427,7 +405,7 @@ private void evictQueryResultRegion(QueryResultsCache cache) {
427405
public void evictQueryRegions() {
428406
LOG.evictingAllQueryRegions();
429407
evictQueryResultRegion( defaultQueryResultsCache );
430-
for ( QueryResultsCache cache : namedQueryResultsCacheMap.values() ) {
408+
for ( var cache : namedQueryResultsCacheMap.values() ) {
431409
evictQueryResultRegion( cache );
432410
}
433411
}
@@ -470,7 +448,7 @@ else if ( regionName == null || regionName.equals( getDefaultResultCacheName() )
470448
}
471449
else {
472450
final var existing = namedQueryResultsCacheMap.get( regionName );
473-
return existing != null ? existing : makeQueryResultsRegionAccess( regionName );
451+
return existing != null ? existing : makeQueryResultsCache( regionName );
474452
}
475453
}
476454

@@ -487,21 +465,20 @@ else if ( regionName == null || regionName.equals( getDefaultResultCacheName() )
487465
}
488466
}
489467

490-
protected QueryResultsCache makeQueryResultsRegionAccess(String regionName) {
491-
final var regionAccess = new QueryResultsCacheImpl( getQueryResultsRegion( regionName ), timestampsCache );
468+
protected QueryResultsCache makeQueryResultsCache(String regionName) {
469+
final var regionAccess = new QueryResultsCacheImpl( queryResultsRegion( regionName ), timestampsCache );
492470
namedQueryResultsCacheMap.put( regionName, regionAccess );
493-
legacySecondLevelCacheNames.add( regionName );
494471
return regionAccess;
495472
}
496473

497-
private QueryResultsRegion getQueryResultsRegion(String regionName) {
498-
final Region region = regionsByName.computeIfAbsent( regionName, this::makeQueryResultsRegion );
499-
return region instanceof QueryResultsRegion queryResultsRegion
474+
private QueryResultsRegion queryResultsRegion(String regionName) {
475+
return regionsByName.computeIfAbsent( regionName, this::buildQueryResultsRegion )
476+
instanceof QueryResultsRegion queryResultsRegion
500477
? queryResultsRegion // There was already a different type of Region with the same name.
501-
: queryResultsRegionsByDuplicateName.computeIfAbsent( regionName, this::makeQueryResultsRegion );
478+
: queryResultsRegionsByDuplicateName.computeIfAbsent( regionName, this::buildQueryResultsRegion );
502479
}
503480

504-
protected QueryResultsRegion makeQueryResultsRegion(String regionName) {
481+
protected QueryResultsRegion buildQueryResultsRegion(String regionName) {
505482
return regionFactory.buildQueryResultsRegion( regionName, getSessionFactory() );
506483
}
507484

@@ -544,7 +521,6 @@ public void close() {
544521
}
545522

546523

547-
548524
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
549525
// JPA-defined methods
550526

@@ -567,8 +543,6 @@ public void evict(Class cls) {
567543
}
568544

569545

570-
571-
572546
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
573547
// Deprecations
574548

0 commit comments

Comments
 (0)