From 9f50157a607727adb23a078f60d0a65777e8ad79 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Thu, 14 Dec 2017 11:37:45 -0500 Subject: [PATCH] =?UTF-8?q?HHH-12146=C2=A0=20-=20Support=20enabling=20cach?= =?UTF-8?q?ing=20at=20any=20level=20within=20a=20mapped=20hierarchy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/hibernate/cfg/annotations/EntityBinder.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java index 51262e13d9..ac298b95d2 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java @@ -600,7 +600,7 @@ public void applyCaching( } } - cacheConcurrentStrategy = effectiveCacheAnn.usage().name(); + cacheConcurrentStrategy = resolveCacheConcurrencyStrategy( effectiveCacheAnn.usage() ); cacheRegion = effectiveCacheAnn.region(); switch ( effectiveCacheAnn.include().toLowerCase( Locale.ROOT ) ) { case "all": { @@ -674,6 +674,11 @@ else if ( explicitCacheableAnn == null && persistentClass.getSuperclass() != nul } } + private static String resolveCacheConcurrencyStrategy(CacheConcurrencyStrategy strategy) { + final org.hibernate.cache.spi.access.AccessType accessType = strategy.toAccessType(); + return accessType == null ? null : accessType.getExternalName(); + } + private static Cache buildCacheMock(String region, MetadataBuildingContext context) { return new LocalCacheAnnotationStub( region, determineCacheConcurrencyStrategy( context ) ); }