mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-21 03:44:21 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user