From 9ee5383721d40820f36cfbc30618b8a56e9b348b Mon Sep 17 00:00:00 2001 From: Jeremy Bauer Date: Mon, 6 Jul 2009 19:06:19 +0000 Subject: [PATCH] OPENJPA-1155 Committing code contributed by Dianne Richards. This update ensures that all entities, especially those loaded during detachment get cascaded during detach. git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@791568 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/openjpa/kernel/BrokerImpl.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java index 58dd46926..2ab7e6b0d 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java @@ -3321,8 +3321,17 @@ public class BrokerImpl if (call == null) call = _call; - new DetachManager(this, true, call).detachAll - (new ManagedObjectCollection(states)); + // Make sure ALL entities are detached, even new ones that are loaded + // during the detach processing + boolean origCascade = _compat.getCascadeWithDetach(); + _compat.setCascadeWithDetach(true); + try { + new DetachManager(this, true, call) + .detachAll(new ManagedObjectCollection(states)); + } + finally { + _compat.setCascadeWithDetach(origCascade); + } } public Object attach(Object obj, boolean copyNew, OpCallbacks call) {