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 0c6f0c5088..18390ab555 100644 --- a/ebean-api/src/main/java/io/ebean/common/BeanSet.java +++ b/ebean-api/src/main/java/io/ebean/common/BeanSet.java @@ -117,7 +117,7 @@ private void initClear() { try { if (set == null) { if (!disableLazyLoad && modifyListening) { - lazyLoadCollection(true); + lazyLoadCollection(false); } else { set = new LinkedHashSet<>(); } @@ -134,7 +134,7 @@ private void init() { if (disableLazyLoad) { set = new LinkedHashSet<>(); } else { - lazyLoadCollection(true); + lazyLoadCollection(false); } } } finally { diff --git a/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java b/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java index dcbc3c32b8..cb3c932ea1 100644 --- a/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java +++ b/ebean-core/src/main/java/io/ebeaninternal/api/LoadManyRequest.java @@ -97,8 +97,12 @@ public SpiQuery createQuery(SpiEbeanServer server) { // potentially changes the joins, selected properties, cache mode loadContext.configureQuery(query); if (onlyIds) { - // lazy loading invoked via clear() and removeAll() - query.select(many.targetIdProperty()); + String mapKey = many.mapKey(); + if (mapKey != null) { + query.select(mapKey); + } else { + query.select(many.targetIdProperty()); + } } return query; }