| withhttps://hibernate.atlassian.net/browse/HHH-12425 the Loader postpones the call to TwoPhaseLoad#afterInitialize(). What happens with a is that Loader#initilizeEntitiesAndCollection:
- First calls TwoPhaseLoad#initilizeEntity() that triggers a call to StatelessSessionImpl#get()
public Object get(String entityName, Serializable id, LockMode lockMode) {
....
if ( temporaryPersistenceContext.isLoadFinished() ) {
temporaryPersistenceContext.clear();
}
return result;
}
that clears the PersistenceContext
- Then calls{{TwoPhaseLoad#afterInitialize()}}
public static void afterInitialize( final Object entity, final SharedSessionContractImplementor session) {
...
final EntityEntry entityEntry = persistenceContext.getEntry( entity );
entityEntry.getPersister().afterInitialize( entity, session );
}
but the PersistenceContext has been previously cleared so entityEntry is null and the call to entityEntry.getPersister() causes a NPE. |