Fix for #70 - @PrivateOwned makes Ebean try to remove non persistent objects from DB and throws OptimisticLockException

This commit is contained in:
Rob Bygrave
2014-03-15 13:48:56 +13:00
parent 5bd454bdc0
commit f0dd069ed2
2 changed files with 10 additions and 1 deletions
@@ -764,7 +764,14 @@ public final class DefaultPersister implements Persister {
// increase depth for batching order
t.depth(+1);
for (Object removedBean : modifyRemovals) {
deleteRecurse(removedBean, t);
if (removedBean instanceof EntityBean) {
EntityBean eb = (EntityBean)removedBean;
if (eb._ebean_getIntercept().isLoaded()) {
// only delete if the bean was loaded meaning that
// it is know to exist in the DB
deleteRecurse(removedBean, t);
}
}
}
t.depth(-1);
}