HHH-15640 ElementCollection with SubSelect FetchMode throws NPE, ownerEntry is null

This commit is contained in:
Andrea Boriero 2022-11-10 16:18:38 +01:00 committed by Andrea Boriero
parent 7337e0be2e
commit 3a0b5feda0
1 changed files with 20 additions and 17 deletions

View File

@ -86,13 +86,15 @@ public class CollectionLoaderSubSelectFetch implements CollectionLoader {
final PersistentCollection<?> collection = persistenceContext.getCollection( collectionKey );
attributeMapping.getCollectionDescriptor().getCollectionType().getKeyOfOwner( collection.getOwner(), session );
final EntityEntry ownerEntry = persistenceContext.getEntry( collection.getOwner() );
final BatchFetchQueue batchFetchQueue = persistenceContext.getBatchFetchQueue();
final EntityEntry ownerEntry = persistenceContext.getEntry( collection.getOwner() );
List<PersistentCollection<?>> subSelectFetchedCollections = null;
if ( ownerEntry != null ) {
final EntityKey triggerKeyOwnerKey = ownerEntry.getEntityKey();
final SubselectFetch registeredFetch = batchFetchQueue.getSubselect( triggerKeyOwnerKey );
List<PersistentCollection<?>> subSelectFetchedCollections = null;
if ( registeredFetch != null ) {
subSelectFetchedCollections = CollectionHelper.arrayList( registeredFetch.getResultingEntityKeys().size() );
subSelectFetchedCollections = CollectionHelper.arrayList(
registeredFetch.getResultingEntityKeys().size() );
// there was one, so we want to make sure to prepare the corresponding collection
// reference for reading
@ -112,6 +114,7 @@ public class CollectionLoaderSubSelectFetch implements CollectionLoader {
}
}
}
}
final JdbcSelect jdbcSelect = sqlAstTranslatorFactory
.buildSelectTranslator( sessionFactory, sqlAst )