mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-18 17:15:02 +00:00
HHH-13665 selecting an Entity annotated with @Immutalbe but not with @Cachable causes a NPE when use_reference_entries is enabled
This commit is contained in:
parent
8d9eb04d16
commit
c392d03bf1
@ -1730,6 +1730,7 @@ private Object instanceNotYetLoaded(
|
|||||||
// see if the entity defines reference caching, and if so use the cached reference (if one).
|
// see if the entity defines reference caching, and if so use the cached reference (if one).
|
||||||
if ( session.getCacheMode().isGetEnabled() && persister.canUseReferenceCacheEntries() ) {
|
if ( session.getCacheMode().isGetEnabled() && persister.canUseReferenceCacheEntries() ) {
|
||||||
final EntityDataAccess cache = persister.getCacheAccessStrategy();
|
final EntityDataAccess cache = persister.getCacheAccessStrategy();
|
||||||
|
if ( cache != null ) {
|
||||||
final Object ck = cache.generateCacheKey(
|
final Object ck = cache.generateCacheKey(
|
||||||
key.getIdentifier(),
|
key.getIdentifier(),
|
||||||
persister,
|
persister,
|
||||||
@ -1738,10 +1739,14 @@ private Object instanceNotYetLoaded(
|
|||||||
);
|
);
|
||||||
final Object cachedEntry = CacheHelper.fromSharedCache( session, ck, cache );
|
final Object cachedEntry = CacheHelper.fromSharedCache( session, ck, cache );
|
||||||
if ( cachedEntry != null ) {
|
if ( cachedEntry != null ) {
|
||||||
CacheEntry entry = (CacheEntry) persister.getCacheEntryStructure().destructure( cachedEntry, factory );
|
CacheEntry entry = (CacheEntry) persister.getCacheEntryStructure().destructure(
|
||||||
|
cachedEntry,
|
||||||
|
factory
|
||||||
|
);
|
||||||
return ( (ReferenceCacheEntryImpl) entry ).getReference();
|
return ( (ReferenceCacheEntryImpl) entry ).getReference();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final Object object;
|
final Object object;
|
||||||
if ( optionalObjectKey != null && key.equals( optionalObjectKey ) ) {
|
if ( optionalObjectKey != null && key.equals( optionalObjectKey ) ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user