From 2c553f3290f01c6eeb3e2b75d89428e9b99712e3 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Tue, 26 Jul 2016 16:22:04 -0700 Subject: [PATCH] HHH-10993 : NPE when Lazy loading collection without transaction for bytecode enhanced entitie --- .../engine/internal/AbstractEntityEntry.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/AbstractEntityEntry.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/AbstractEntityEntry.java index 7c8cdd35fb..fa499070d3 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/AbstractEntityEntry.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/AbstractEntityEntry.java @@ -323,11 +323,14 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry { @Override public void overwriteLoadedStateCollectionValue(String propertyName, PersistentCollection collection) { - assert propertyName != null; - assert loadedState != null; + // nothing to do if status is READ_ONLY + if ( getStatus() != Status.READ_ONLY ) { + assert propertyName != null; + assert loadedState != null; - final int propertyIndex = ( (UniqueKeyLoadable) persister ).getPropertyIndex( propertyName ); - loadedState[propertyIndex] = collection; + final int propertyIndex = ( (UniqueKeyLoadable) persister ).getPropertyIndex( propertyName ); + loadedState[propertyIndex] = collection; + } } @Override