HHH-15453 java.lang.NullPointerException: Cannot invoke org.hibernate.engine.spi.EntityEntry.getEntityKey() because ownerEntry is null

This commit is contained in:
Andrea Boriero 2022-08-19 22:15:58 +02:00 committed by Christian Beikov
parent ed4f399723
commit d862b086ea
2 changed files with 15 additions and 1 deletions

View File

@ -282,7 +282,11 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
}
}
else {
if ( !session.isTransactionInProgress() ) {
/*
Whenever the collection lazy loading is triggered during the loading process,
closing the connection will cause an error when RowProcessingStateStandardImpl#next() will be called.
*/
if ( !session.isTransactionInProgress() && session.getPersistenceContext().isLoadFinished() ) {
session.getJdbcCoordinator().afterTransaction();
}
}

View File

@ -101,6 +101,11 @@ public abstract class AbstractCollectionInitializer implements CollectionInitial
if ( loadingEntry != null ) {
collectionInstance = loadingEntry.getCollectionInstance();
if ( collectionInstance.getOwner() == null ) {
parentAccess.registerResolutionListener(
owner -> collectionInstance.setOwner( owner )
);
}
return;
}
@ -108,6 +113,11 @@ public abstract class AbstractCollectionInitializer implements CollectionInitial
if ( existing != null ) {
collectionInstance = existing;
if ( collectionInstance.getOwner() == null ) {
parentAccess.registerResolutionListener(
owner -> collectionInstance.setOwner( owner )
);
}
return;
}