@@ -260,10 +260,8 @@ public void evictEntityData(String entityName, Object identifier) {
260
260
final EntityDataAccess cacheAccess = persister .getCacheAccessStrategy ();
261
261
if ( cacheAccess != null ) {
262
262
if ( LOG .isDebugEnabled () ) {
263
- LOG .debugf (
264
- "Evicting second-level cache: %s" ,
265
- infoString ( persister , identifier , sessionFactory )
266
- );
263
+ LOG .debug ( "Evicting entity second-level cache: "
264
+ + infoString ( persister , identifier , sessionFactory ) );
267
265
}
268
266
269
267
final Object cacheKey =
@@ -308,7 +306,7 @@ protected void evictEntityData(EntityPersister entityDescriptor) {
308
306
private void evictEntityData (NavigableRole navigableRole , EntityDataAccess cacheAccess ) {
309
307
if ( cacheAccess != null ) {
310
308
if ( LOG .isDebugEnabled () ) {
311
- LOG .debugf ( "Evicting entity cache: %s" , navigableRole .getFullPath () );
309
+ LOG .debug ( "Evicting entity second-level cache: " + navigableRole .getFullPath () );
312
310
}
313
311
cacheAccess .evictAll ();
314
312
}
@@ -347,7 +345,7 @@ public void evictNaturalIdData() {
347
345
private void evictNaturalIdData (NavigableRole rootEntityRole , NaturalIdDataAccess cacheAccess ) {
348
346
if ( cacheAccess != null ) {
349
347
if ( LOG .isDebugEnabled () ) {
350
- LOG .debugf ( "Evicting natural-id cache: %s" , rootEntityRole .getFullPath () );
348
+ LOG .debug ( "Evicting natural-id cache: " + rootEntityRole .getFullPath () );
351
349
}
352
350
cacheAccess .evictAll ();
353
351
}
@@ -378,10 +376,8 @@ public void evictCollectionData(String role, Object ownerIdentifier) {
378
376
final CollectionDataAccess cacheAccess = persister .getCacheAccessStrategy ();
379
377
if ( cacheAccess != null ) {
380
378
if ( LOG .isDebugEnabled () ) {
381
- LOG .debugf (
382
- "Evicting second-level cache: %s" ,
383
- collectionInfoString ( persister , ownerIdentifier , sessionFactory )
384
- );
379
+ LOG .debug ( "Evicting collection second-level cache: "
380
+ + collectionInfoString ( persister , ownerIdentifier , sessionFactory ) );
385
381
}
386
382
387
383
final Object cacheKey =
@@ -403,7 +399,7 @@ private void evictCollectionData(CollectionPersister collectionDescriptor) {
403
399
private void evictCollectionData (NavigableRole navigableRole , CollectionDataAccess cacheAccess ) {
404
400
if ( cacheAccess != null ) {
405
401
if ( LOG .isDebugEnabled () ) {
406
- LOG .debugf ( "Evicting second-level cache: %s" , navigableRole .getFullPath () );
402
+ LOG .debug ( "Evicting collection second-level cache: " + navigableRole .getFullPath () );
407
403
}
408
404
cacheAccess .evictAll ();
409
405
}
@@ -440,7 +436,7 @@ public void evictQueryRegion(String regionName) {
440
436
private void evictQueryResultRegion (QueryResultsCache cache ) {
441
437
if ( cache != null ) {
442
438
if ( LOG .isDebugEnabled () ) {
443
- LOG .debugf ( "Evicting query cache, region: %s" , cache .getRegion ().getName () );
439
+ LOG .debug ( "Evicting query cache region: " + cache .getRegion ().getName () );
444
440
}
445
441
cache .clear ();
446
442
}
@@ -449,7 +445,7 @@ private void evictQueryResultRegion(QueryResultsCache cache) {
449
445
@ Override
450
446
public void evictQueryRegions () {
451
447
if ( LOG .isDebugEnabled () ) {
452
- LOG .debug ( "Evicting cache of all query regions. " );
448
+ LOG .debug ( "Evicting cache of all query regions" );
453
449
}
454
450
455
451
evictQueryResultRegion ( defaultQueryResultsCache );
@@ -507,20 +503,10 @@ protected QueryResultsCache makeQueryResultsRegionAccess(String regionName) {
507
503
}
508
504
509
505
private QueryResultsRegion getQueryResultsRegion (String regionName ) {
510
- final Region region = regionsByName .computeIfAbsent (
511
- regionName ,
512
- this ::makeQueryResultsRegion
513
- );
514
- if ( region instanceof QueryResultsRegion queryResultsRegion ) {
515
- return queryResultsRegion ;
516
- }
517
- else {
518
- // There was already a different type of Region with the same name.
519
- return queryResultsRegionsByDuplicateName .computeIfAbsent (
520
- regionName ,
521
- this ::makeQueryResultsRegion
522
- );
523
- }
506
+ final Region region = regionsByName .computeIfAbsent ( regionName , this ::makeQueryResultsRegion );
507
+ return region instanceof QueryResultsRegion queryResultsRegion
508
+ ? queryResultsRegion // There was already a different type of Region with the same name.
509
+ : queryResultsRegionsByDuplicateName .computeIfAbsent ( regionName , this ::makeQueryResultsRegion );
524
510
}
525
511
526
512
protected QueryResultsRegion makeQueryResultsRegion (String regionName ) {
@@ -544,16 +530,19 @@ public void evictRegion(String regionName) {
544
530
545
531
@ Override
546
532
@ SuppressWarnings ("unchecked" )
547
- public <T > T unwrap (Class <T > cls ) {
548
- if ( org .hibernate .Cache .class .isAssignableFrom ( cls ) ) {
533
+ public <T > T unwrap (Class <T > type ) {
534
+ if ( org .hibernate .Cache .class .isAssignableFrom ( type ) ) {
535
+ return (T ) this ;
536
+ }
537
+ if ( org .hibernate .cache .spi .CacheImplementor .class .isAssignableFrom ( type ) ) {
549
538
return (T ) this ;
550
539
}
551
540
552
- if ( RegionFactory .class .isAssignableFrom ( cls ) ) {
541
+ if ( RegionFactory .class .isAssignableFrom ( type ) ) {
553
542
return (T ) regionFactory ;
554
543
}
555
544
556
- throw new PersistenceException ( "Hibernate cannot unwrap Cache as " + cls .getName () );
545
+ throw new PersistenceException ( "Hibernate cannot unwrap Cache as ' " + type .getName () + "'" );
557
546
}
558
547
559
548
@ Override
0 commit comments