NPE when loading a list of self joined entities (depending on package name)

Description

I get a NullPointerException when loading a list of self joined entities. The NPE happens here:

org.hibernate.engine.internal.StatefulPersistenceContext.getLoadedCollectionOwnerOrNull(PersistentCollection)

This is a subsequent call from hashCode() on my entity.

The problem is that this NPE is thrown depending on the package/class name of the entity. In the attached example the entities from package c.s.p.f.yg can be loaded successfully, the ones from package other not. There are two unit tests that show that behavior (unfortunately it does not work when running both tests at the same time, so call them independently).

Surprisingly the same works when calling

instead of

See ParentOTest. Why is there a difference between these two methods?

Environment

None

Assignee

Unassigned

Reporter

Yan Graf

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure