mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-18 14:58:47 +00:00
Fix for issue 46 - Persistence Context Cache not cleared when deleting a collection of entities in a running transaction
This commit is contained in:
1 parent
1a9a4c957c
commit
c6019bf3c5
5 files changed
+172
-10
No files matched your search
@@ -19,6 +19,7 @@ import com.avaje.ebean.bean.BeanCollection;
|
||||
import com.avaje.ebean.bean.BeanCollection.ModifyListenMode;
|
||||
import com.avaje.ebean.bean.EntityBean;
|
||||
import com.avaje.ebean.bean.EntityBeanIntercept;
|
||||
import com.avaje.ebean.bean.PersistenceContext;
|
||||
import com.avaje.ebeaninternal.api.SpiEbeanServer;
|
||||
import com.avaje.ebeaninternal.api.SpiTransaction;
|
||||
import com.avaje.ebeaninternal.api.SpiUpdate;
|
||||
@@ -38,6 +39,7 @@ import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocMany;
|
||||
import com.avaje.ebeaninternal.server.deploy.BeanPropertyAssocOne;
|
||||
import com.avaje.ebeaninternal.server.deploy.IntersectionRow;
|
||||
import com.avaje.ebeaninternal.server.deploy.ManyType;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -538,7 +540,18 @@ public final class DefaultPersister implements Persister {
|
||||
} else {
|
||||
t.getEvent().addDeleteById(descriptor, id);
|
||||
}
|
||||
return executeSqlUpdate(deleteById, t);
|
||||
int rows = executeSqlUpdate(deleteById, t);
|
||||
|
||||
// Delete from the persistence context so that it can't be fetched again later
|
||||
PersistenceContext persistenceContext = ((SpiTransaction)t).getPersistenceContext();
|
||||
if (idList != null) {
|
||||
for (Object idValue : idList) {
|
||||
persistenceContext.deleted(descriptor.getBeanType(), idValue);
|
||||
}
|
||||
} else {
|
||||
persistenceContext.deleted(descriptor.getBeanType(), id);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user