HHH-12587 - Fix NullPointerException when flushing entity with CacheConcurrencyStrategy.NONE.

This commit is contained in:
Chris Cranford 2018-05-22 17:45:03 -04:00
parent 3aac27d369
commit 21bd9a6a9f
1 changed files with 9 additions and 1 deletions

View File

@ -534,7 +534,7 @@ public abstract class AbstractEntityPersister
this.navigableRole = new NavigableRole( persistentClass.getEntityName() );
if ( creationContext.getSessionFactory().getSessionFactoryOptions().isSecondLevelCacheEnabled() ) {
this.canWriteToCache = persistentClass.isCached();
this.canWriteToCache = determineCanWriteToCache( persistentClass, cacheAccessStrategy );
this.canReadFromCache = determineCanReadFromCache( persistentClass );
this.cacheAccessStrategy = cacheAccessStrategy;
this.isLazyPropertiesCacheable = persistentClass.getRootClass().isLazyPropertiesCacheable();
@ -907,6 +907,14 @@ public abstract class AbstractEntityPersister
return false;
}
private boolean determineCanWriteToCache(PersistentClass persistentClass, EntityDataAccess cacheAccessStrategy) {
if ( cacheAccessStrategy == null ) {
return false;
}
return persistentClass.isCached();
}
@SuppressWarnings("unchecked")
private boolean determineCanReadFromCache(PersistentClass persistentClass) {
if ( persistentClass.isCached() ) {