Follow up #3173 - Change BeanSet clear() to lazy load ALL properties

To avoid the 1+N lazy loading queries that are invoked due to the clear()
when the entity bean in the Set has a hashCode/equals implementation
This commit is contained in:
Rob Bygrave
2023-08-29 21:20:19 +12:00
parent 4b9d4d0a90
commit 5377454476
2 changed files with 3 additions and 5 deletions
@@ -119,7 +119,7 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
try {
if (set == null) {
if (!disableLazyLoad && modifyListening) {
lazyLoadCollection(true);
lazyLoadCollection(false);
} else {
set = new LinkedHashSet<>();
}
@@ -51,10 +51,8 @@ class TestO2MSet {
employees.clear();
sql = LoggedSql.collect();
assertThat(sql).hasSize(3);
assertThat(sql.get(0)).contains("select t0.department_id, t0.id from o2_memp t0 where (t0.department_id)");
assertThat(sql.get(1)).contains("select t0.id, t0.code, t0.name, t0.department_id from o2_memp t0 where t0.id = ?");
assertThat(sql.get(2)).contains("select t0.id, t0.code, t0.name, t0.department_id from o2_memp t0 where t0.id = ?");
assertThat(sql).hasSize(1);
assertThat(sql.get(0)).contains("select t0.department_id, t0.id, t0.code, t0.name, t0.department_id from o2_memp t0 where (t0.department_id)");
final O2MEmp employee2 = new O2MEmp("After1", "Code3");
employees.add(employee2);