From 8d6c318797ad3e7048cdfeae4b2fcec49790e4e3 Mon Sep 17 00:00:00 2001 From: Nicolas Noffke Date: Wed, 25 Feb 2015 14:08:45 +0100 Subject: [PATCH] HHH-9629 Use root entity name for constructing cache key --- .../src/main/java/org/hibernate/engine/spi/BatchFetchQueue.java | 2 +- .../org/hibernate/persister/entity/AbstractEntityPersister.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/BatchFetchQueue.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/BatchFetchQueue.java index 171c083767..e9c7f91305 100755 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/BatchFetchQueue.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/BatchFetchQueue.java @@ -222,7 +222,7 @@ public class BatchFetchQueue { final CacheKey key = context.getSession().generateCacheKey( entityKey.getIdentifier(), persister.getIdentifierType(), - entityKey.getEntityName() + persister.getRootEntityName() ); return CacheHelper.fromSharedCache( context.getSession(), key, persister.getCacheAccessStrategy() ) != null; } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 339d2f3276..076231f6b7 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -1235,7 +1235,7 @@ public abstract class AbstractEntityPersister } if ( session.getCacheMode().isGetEnabled() && hasCache() ) { - final CacheKey cacheKey = session.generateCacheKey( id, getIdentifierType(), getEntityName() ); + final CacheKey cacheKey = session.generateCacheKey( id, getIdentifierType(), getRootEntityName() ); final Object ce = CacheHelper.fromSharedCache( session, cacheKey, getCacheAccessStrategy() ); if ( ce != null ) { final CacheEntry cacheEntry = (CacheEntry) getCacheEntryStructure().destructure(ce, factory);