From f8243a60073fb5622a27f56147f7db3ad5975b79 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 (cherry picked from commit 2c553f3290f01c6eeb3e2b75d89428e9b99712e3) --- .../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 6c6750589b..83c001b7c9 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 @@ -335,11 +335,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