Skip to content

Commit c436a8c

Browse files
unknownoskarb
authored andcommitted
Stateless Session with deduplicated result with join fetch
1 parent 6823bc4 commit c436a8c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/NHibernate/Impl/StatelessSessionImpl.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,13 @@ public override bool IsEventSource
316316
public override object GetEntityUsingInterceptor(EntityKey key)
317317
{
318318
CheckAndUpdateSessionStatus();
319-
return null;
319+
// while a pending Query we should use existing temporary entities so a join fetch does not create multiple instances
320+
// of the same parent item
321+
object obj;
322+
if (temporaryPersistenceContext.EntitiesByKey.TryGetValue(key, out obj))
323+
return obj;
324+
else
325+
return null;
320326
}
321327

322328
public override IPersistenceContext PersistenceContext

0 commit comments

Comments
 (0)