mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
Fix #23 - Covers: unit tests for: stateless updates which fails when executing without...
This commit is contained in:
@@ -158,6 +158,18 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> {
|
||||
help.add(bc, detailBean);
|
||||
}
|
||||
|
||||
public boolean isEmptyBeanCollection(EntityBean bean) {
|
||||
Object val = getValue(bean);
|
||||
if (val == null) {
|
||||
return true;
|
||||
}
|
||||
if (val instanceof BeanCollection<?>) {
|
||||
// if empty and not been cleared or elements removed
|
||||
return ((BeanCollection<?>)val).isEmptyAndUntouched();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValue(EntityBean bean) {
|
||||
return super.getValue(bean);
|
||||
|
||||
@@ -565,7 +565,10 @@ public final class DefaultPersister implements Persister {
|
||||
// many's with cascade save
|
||||
BeanPropertyAssocMany<?>[] manys = desc.propertiesManySave();
|
||||
for (int i = 0; i < manys.length; i++) {
|
||||
saveMany(new SaveManyPropRequest(insertedParent, manys[i], parentBean, request));
|
||||
// check that property is loaded and not empty uninitialised collection
|
||||
if (request.isLoadedProperty(manys[i]) && !manys[i].isEmptyBeanCollection(parentBean)) {
|
||||
saveMany(new SaveManyPropRequest(insertedParent, manys[i], parentBean, request));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,7 +608,7 @@ public final class DefaultPersister implements Persister {
|
||||
public boolean isSaveIntersection() {
|
||||
return t.isSaveAssocManyIntersection(many.getIntersectionTableJoin().getTable(), many.getBeanDescriptor().getName());
|
||||
}
|
||||
|
||||
|
||||
private Object getValue() {
|
||||
return many.getValue(parentBean);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user