Skip to content

Commit e8a8282

Browse files
fixup! Resolve collection owner correctly in case of property-ref
Handle possibly null case Co-Authored-By: Alexander Zaytsev <hazzik@gmail.com>
1 parent c06f33e commit e8a8282

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/NHibernate/Async/Loader/Loader.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,35 @@ private async Task<object[]> GetRowAsync(DbDataReader rs, ILoadable[] persisters
652652
// been cached too for all its unique keys, provided its persister implement it. With this new
653653
// way of caching unique keys, it is no more needed to handle caching for alreadyLoaded path
654654
// too.
655-
await ((persister as IUniqueKeyLoadable).CacheByUniqueKeysAsync(obj, session, cancellationToken)).ConfigureAwait(false);
655+
var cacheByUniqueKeysTask = (persister as IUniqueKeyLoadable)?.CacheByUniqueKeysAsync(obj, session, cancellationToken);
656+
657+
// IUniqueKeyLoadable.CacheByUniqueKeys caches all unique keys of the entity, regardless of
658+
// associations loaded by the query. So if the entity is already loaded, it has forcibly already
659+
// been cached too for all its unique keys, provided its persister implement it. With this new
660+
// way of caching unique keys, it is no more needed to handle caching for alreadyLoaded path
661+
// too.
662+
if (cacheByUniqueKeysTask != null)
663+
664+
// IUniqueKeyLoadable.CacheByUniqueKeys caches all unique keys of the entity, regardless of
665+
// associations loaded by the query. So if the entity is already loaded, it has forcibly already
666+
// been cached too for all its unique keys, provided its persister implement it. With this new
667+
// way of caching unique keys, it is no more needed to handle caching for alreadyLoaded path
668+
// too.
669+
{
670+
671+
// IUniqueKeyLoadable.CacheByUniqueKeys caches all unique keys of the entity, regardless of
672+
// associations loaded by the query. So if the entity is already loaded, it has forcibly already
673+
// been cached too for all its unique keys, provided its persister implement it. With this new
674+
// way of caching unique keys, it is no more needed to handle caching for alreadyLoaded path
675+
// too.
676+
await (cacheByUniqueKeysTask).ConfigureAwait(false);
677+
678+
// IUniqueKeyLoadable.CacheByUniqueKeys caches all unique keys of the entity, regardless of
679+
// associations loaded by the query. So if the entity is already loaded, it has forcibly already
680+
// been cached too for all its unique keys, provided its persister implement it. With this new
681+
// way of caching unique keys, it is no more needed to handle caching for alreadyLoaded path
682+
// too.
683+
}
656684
}
657685
// 6.0 TODO: this call is nor more needed for up-to-date persisters, remove once CacheByUniqueKeys
658686
// is merged in IUniqueKeyLoadable interface instead of being an extension method

src/NHibernate/Loader/Loader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ private object[] GetRow(DbDataReader rs, ILoadable[] persisters, EntityKey[] key
987987
// been cached too for all its unique keys, provided its persister implement it. With this new
988988
// way of caching unique keys, it is no more needed to handle caching for alreadyLoaded path
989989
// too.
990-
(persister as IUniqueKeyLoadable).CacheByUniqueKeys(obj, session);
990+
(persister as IUniqueKeyLoadable)?.CacheByUniqueKeys(obj, session);
991991
}
992992
// 6.0 TODO: this call is nor more needed for up-to-date persisters, remove once CacheByUniqueKeys
993993
// is merged in IUniqueKeyLoadable interface instead of being an extension method

0 commit comments

Comments
 (0)