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
List<Child> result = newSession.createQuery("from Child").list();
instead of
List<ChildO> result = newSession.createCriteria(ChildO.class).list();
See ParentOTest. Why is there a difference between these two methods?
|