Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 6669 invoked from network); 15 May 2008 21:23:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 May 2008 21:23:48 -0000 Received: (qmail 14755 invoked by uid 500); 15 May 2008 21:23:47 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 14738 invoked by uid 500); 15 May 2008 21:23:47 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 14727 invoked by uid 99); 15 May 2008 21:23:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 May 2008 14:23:47 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [192.245.12.244] (HELO mite.sproing.net) (192.245.12.244) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 May 2008 21:22:59 +0000 Received: from localhost ([127.0.0.1] ident=bert) by mite.sproing.net with esmtp (Exim 4.63) (envelope-from ) id 1Jwkuv-0001nE-TR for users@openjpa.apache.org; Thu, 15 May 2008 14:23:14 -0700 Message-Id: From: Bert Bee-Lindgren To: users@openjpa.apache.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Refresh after another EM removes one-to-many member Date: Thu, 15 May 2008 17:23:13 -0400 X-Mailer: Apple Mail (2.919.2) X-Virus-Checked: Checked by ClamAV on apache.org I have two EntityManagers EM1 has an object r1 which has a one-to-many relationship [CascadeType.ALL] myTees containing t1 EM2 starts transaction reads r1 removes t1 from r1.myTees commits transaction When EM1 does a refresh(r1), it gets the following exception: Caused by: org.apache.openjpa.persistence.EntityNotFoundException: The follwing instnaces do not exist in the data store: [88979 [org.apache.openjpa.util.IntId]] at org .apache .openjpa.kernel.BrokerImpl.newObjectNotFoundException(BrokerImpl.java: 4343) at org.apache.openjpa.kernel.BrokerImpl.refreshInternal(BrokerImpl.java: 2796) ... 25 more My expectation is that r1.myTees would simply be an empty collection after the refresh. An hibernate thread seemed to trace this to a cascade refresh being done before the relationships destinations were rebuilt. From http://forum.hibernate.org/viewtopic.php?t=981635&highlight= Looking the hibernate code (admittedly, core hibernate), the DefaultRefreshEventListener.onRefresh method has a call to evictCachedCollections but after the refresh has been cascaded to its children. It seems like this should happen before the refresh is cascaded, or at least be an option. Am I wrong to expect refresh to work this way? Should I always do EM1.find()? Thanks, Bert