ToMany collections that are not loaded on freeze are marked unloaded

They are marked as unloaded which means accessing the collection will
throw a PersistenceException.

e.g. customer.getOrders() will throw PersistenceException rather than
return an empty list.
This commit is contained in:
Rob Bygrave
2024-01-30 22:32:49 +13:00
parent bc302b19db
commit 93ae5f2b7c
5 changed files with 18 additions and 6 deletions
@@ -46,7 +46,8 @@ public final class BeanList<E> extends AbstractBeanCollection<E> implements List
@Override
public Object freeze() {
return list == null ? Collections.emptyList() : Collections.unmodifiableList(list);
// null -> illegal to access reference collection
return list == null ? null : Collections.unmodifiableList(list);
}
@Override
@@ -39,7 +39,8 @@ public final class BeanMap<K, E> extends AbstractBeanCollection<E> implements Ma
@Override
public Object freeze() {
return map == null ? Collections.emptyMap() : Collections.unmodifiableMap(map);
// null -> illegal to access reference collection
return map == null ? null : Collections.unmodifiableMap(map);
}
@Override
@@ -42,7 +42,8 @@ public final class BeanSet<E> extends AbstractBeanCollection<E> implements Set<E
@Override
public Object freeze() {
return set == null ? Collections.emptySet() : Collections.unmodifiableSet(set);
// null -> illegal to access reference collection
return set == null ? null : Collections.unmodifiableSet(set);
}
@Override