From 297c1d7abb2b28bb5457a9f51e14644159a52193 Mon Sep 17 00:00:00 2001 From: Robin Bygrave Date: Mon, 1 Mar 2021 20:27:50 +1300 Subject: [PATCH] #2179 - Improved fix for (2179) Fetch on nested one-to-many collections results in duplicates The improvement here is that SqlTreeNodeManyRoot uses load and isContextBean() so that it only checks if the collection already contains the detailBean if the detailBean was already in the persistence context (aka not newly loaded and added). The vast majority case is that detailBean is loaded fresh so for the common case we can skip the extra collection contains() check. --- .../main/java/io/ebean/common/BeanSet.java | 5 +- .../server/query/SqlTreeNodeBean.java | 48 ++++++++++++------- .../server/query/SqlTreeNodeManyRoot.java | 13 ++--- 3 files changed, 41 insertions(+), 25 deletions(-) diff --git a/ebean-api/src/main/java/io/ebean/common/BeanSet.java b/ebean-api/src/main/java/io/ebean/common/BeanSet.java index 91f0ae672..880ece106 100644 --- a/ebean-api/src/main/java/io/ebean/common/BeanSet.java +++ b/ebean-api/src/main/java/io/ebean/common/BeanSet.java @@ -70,9 +70,8 @@ public final class BeanSet extends AbstractBeanCollection implements Set