PersistenceContext can get cleared before load completes using StatelessSessionImpl
Description
When an association gets loaded eagerly by {{StatelessSessionImpl#internalLoad}} calling {{StatelessSessionImpl#get}}, {{temporaryPersistenceContext}} may get cleared before the load is complete. If this happens, Hibernate will not find an expected {{EntityEntry}}, and {{TwoPhaseLoad#afterInitialize}} will throw a {{NullPointerException}}.
The test case for https://hibernate.atlassian.net/browse/HHH-13633 caused the {{NullPointerException}} because there was a bug that caused a lazy association to be loaded eagerly. Once that bug was fixed by HHH-13633, the problem was no longer reproduced by that test case.
Modifying that test case to make the association eager reproduced this issue again.
When an association gets loaded eagerly by {{StatelessSessionImpl#internalLoad}} calling {{StatelessSessionImpl#get}}, {{temporaryPersistenceContext}} may get cleared before the load is complete. If this happens, Hibernate will not find an expected {{EntityEntry}}, and {{TwoPhaseLoad#afterInitialize}} will throw a {{NullPointerException}}.
The test case for https://hibernate.atlassian.net/browse/HHH-13633 caused the {{NullPointerException}} because there was a bug that caused a lazy association to be loaded eagerly. Once that bug was fixed by HHH-13633, the problem was no longer reproduced by that test case.
Modifying that test case to make the association eager reproduced this issue again.
Original description:
A test case added for https://hibernate.atlassian.net/browse/HHH-13633#icft=HHH-13633 throws
NullPointerException
.@Andrea Boriero found that this commit for https://hibernate.atlassian.net/browse/HHH-12425#icft=HHH-12425 caused the NPE.