Session.load enhanced entity with eager collection loading mapping failded with PropertyAccessException

Description

In case when entity has collection with eager loading mapping like

1 @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.EAGER)

and entities are enhanced with configuration

1 cfg.setProperty( Environment.ENABLE_LAZY_LOAD_NO_TRANS, "true" );

there is error with loading entity by session.load( Parent2.class, parentID ):
...
Caused by: org.hibernate.PropertyAccessException: Exception occurred inside setter of org.hibernate.test.bytecode.enhancement.lazy.Parent2.children
at org.hibernate.property.access.spi.EnhancedSetterMethodImpl.set(EnhancedSetterMethodImpl.java:81)
...
Caused by: java.lang.reflect.InvocationTargetException
...
org.hibernate.property.access.spi.EnhancedSetterMethodImpl.set(EnhancedSetterMethodImpl.java:49)
...
Caused by: java.lang.NullPointerException
at org.hibernate.engine.internal.StatefulPersistenceContext.getLoadedCollectionOwnerOrNull(StatefulPersistenceContext.java:747)
...

In attachment is junit test case to reproduce it.

Environment

None

Status

Assignee

Unassigned

Reporter

LAdO

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

5.0.2

Priority

Major
Configure