We're updating the issue view to help you get more done. 

NPE when Lazy loading collection without transaction for bytecode enhanced entitie

Description

When Lazy loaded collections are accessed outside a transaction for bytecode enhanced entities, a NullPointerException is thrown by org.hibernate.engine.internal.AbstractEntityEntry.overwriteLoadedStateCollectionValue().

This exception occurs when a Lazy Loaded collection is accessed outside a transaction, a temporary session is created to lazy load the collection and the loadedState of the EntityEntry for the PersistenceContext is set to null by;

org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor.loadAttribute()

https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/LazyAttributeLoadingInterceptor.java#L88

This was introduced by

Environment

None

Status

Assignee

Gail Badner

Reporter

John O'Hara

Components

Fix versions

Affects versions

5.0.9
5.2.1

Priority

Major