Skip to content

Commit

Permalink
Merge pull request #3218 from ebean-orm/backport-12x/3173-BeanSet-ini…
Browse files Browse the repository at this point in the history
…t-loading

[12x] Backport of fix for #3173 BeanSet init(), initClear() and BeanMap
  • Loading branch information
rbygrave authored Sep 7, 2023
2 parents 514bba4 + 5b9ef2d commit 88fd59e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ebean-api/src/main/java/io/ebean/common/BeanSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ private void initClear() {
try {
if (set == null) {
if (!disableLazyLoad && modifyListening) {
lazyLoadCollection(true);
lazyLoadCollection(false);
} else {
set = new LinkedHashSet<>();
}
Expand All @@ -134,7 +134,7 @@ private void init() {
if (disableLazyLoad) {
set = new LinkedHashSet<>();
} else {
lazyLoadCollection(true);
lazyLoadCollection(false);
}
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 88fd59e

Please sign in to comment.