Skip to content

Commit d2d49b5

Browse files
Ensure the trouble will not occur for collections
1 parent 1bef543 commit d2d49b5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/NHibernate/Async/Engine/BatchFetchQueue.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ async Task<bool> CheckCacheAndProcessResultAsync()
102102
? collectionKeys.Count - Math.Min(batchSize, collectionKeys.Count)
103103
: 0;
104104
var toIndex = collectionKeys.Count - 1;
105-
var indexes = GetSortedKeyIndexes(collectionKeys, keyIndex.Value, fromIndex, toIndex);
105+
// In case the collection having triggered the load was not registered for batching, load
106+
// most recently registered collections.
107+
var indexes = GetSortedKeyIndexes(collectionKeys, keyIndex ?? -1, fromIndex, toIndex);
106108
if (batchableCache == null)
107109
{
108110
for (var j = 0; j < collectionKeys.Count; j++)

src/NHibernate/Engine/BatchFetchQueue.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,9 @@ bool CheckCacheAndProcessResult()
271271
? collectionKeys.Count - Math.Min(batchSize, collectionKeys.Count)
272272
: 0;
273273
var toIndex = collectionKeys.Count - 1;
274-
var indexes = GetSortedKeyIndexes(collectionKeys, keyIndex.Value, fromIndex, toIndex);
274+
// In case the collection having triggered the load was not registered for batching, load
275+
// most recently registered collections.
276+
var indexes = GetSortedKeyIndexes(collectionKeys, keyIndex ?? -1, fromIndex, toIndex);
275277
if (batchableCache == null)
276278
{
277279
for (var j = 0; j < collectionKeys.Count; j++)

0 commit comments

Comments
 (0)