Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 74423 invoked from network); 13 Apr 2011 14:19:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Apr 2011 14:19:20 -0000 Received: (qmail 26018 invoked by uid 500); 13 Apr 2011 14:19:20 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 25989 invoked by uid 500); 13 Apr 2011 14:19:20 -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 25981 invoked by uid 99); 13 Apr 2011 14:19:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Apr 2011 14:19:20 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of michael.d.dick@gmail.com designates 209.85.161.174 as permitted sender) Received: from [209.85.161.174] (HELO mail-gx0-f174.google.com) (209.85.161.174) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Apr 2011 14:19:14 +0000 Received: by gxk21 with SMTP id 21so313810gxk.33 for ; Wed, 13 Apr 2011 07:18:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=Jfoi+Agjy8ZXef9Xfv71k+E8GCOElmWYtBa00G811Dg=; b=nAkpmW60OAaSNZoAvETL/TPo5cviq3rdJsesFhSWoA67WeELm+UXi3duRQyYNsw8l3 +/AIiMqSL7EcjuKpqKIWbCfp42DIE23HETI/xMhs2bKeq/z8qb2s1uOId1hvSRUa7cl+ xKwsogQjG2IPAWhRCC3voNliMfjjpfbBMWbJ0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=qMY71NPgXtiUjr/Ukyk7AMgkb44nWtcLGsVNwA5rcA9ur6rkjF6za11+qDQW/MmHb/ Kob3iVhXmowtOIHpZ19WZE1Gn2bW7Mg/B7we0/9aZFahA3U0oGrZaEkh/D62otpwtBFh MBZMtuhkGMBCCpoXey2rfniCPOQmXvPi9/n2o= Received: by 10.90.149.16 with SMTP id w16mr564466agd.138.1302704333182; Wed, 13 Apr 2011 07:18:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.90.192.17 with HTTP; Wed, 13 Apr 2011 07:18:33 -0700 (PDT) In-Reply-To: <1C448C478A6B4743AF19DBC3C3DCE13201B7FB4DF055@HMS.hm.local> References: <1C448C478A6B4743AF19DBC3C3DCE13201B7FB4DF04F@HMS.hm.local> <1C448C478A6B4743AF19DBC3C3DCE13201B7FB4DF052@HMS.hm.local> <1C448C478A6B4743AF19DBC3C3DCE13201B7FB4DF055@HMS.hm.local> From: Michael Dick Date: Wed, 13 Apr 2011 09:18:33 -0500 Message-ID: Subject: Re: two issues when not using a DetachedStateField To: users@openjpa.apache.org Content-Type: multipart/alternative; boundary=0016361e89d406d95104a0cd7db1 X-Virus-Checked: Checked by ClamAV on apache.org --0016361e89d406d95104a0cd7db1 Content-Type: text/plain; charset=ISO-8859-1 Hi, I did a quick search through the open issues and there are several reported problems with cascading. I don't know which one fits your scenario the best. It would help me (at least) if I could see the test case you mentioned. I'd recommend either opening a new JIRA and attaching your testcase to it, or posting the testcase to something like pastebin . -mike On Wed, Apr 13, 2011 at 7:59 AM, Henno Vermeulen wrote: > Even though the merge succeeds, there is one big issue with removing the > cascade from the bidirectional relation namely I get that > > event != event.activities.get(0).event > > Could this mean that event is unnecessarily fetched and extra unnecessary > SQL gets executed (I've seen issues on this)? > > -----Oorspronkelijk bericht----- > Van: Henno Vermeulen [mailto:henno@huizemolenaar.nl] > Verzonden: woensdag 13 april 2011 14:40 > Aan: 'users@openjpa.apache.org' > Onderwerp: RE: two issues when not using a DetachedStateField > > Issue 2 also does not occury when Activity to Event is not set to cascade. > The issue also doesn't occur when StringI18N is removed and the object > graph is only three entities deep. So it is quite a complicated combination > of factors: no detached state field, four entities and a cascade from > Activity to Event... > > -----Oorspronkelijk bericht----- > Van: Henno Vermeulen [mailto:henno@huizemolenaar.nl] > Verzonden: woensdag 13 april 2011 14:30 > Aan: 'users@openjpa.apache.org' > Onderwerp: two issues when not using a DetachedStateField > > We use OpenJPA 2.1.0 with build time enhancement. We have a client/server > situation so we always detach + serialize entities on commit using fetch > groups: > > value="fetch-groups(DetachedStateField=false)" /> > > We currently don't use a DetachedStateField or DetachedStateManager because > everything worked fine without them until now. > > I found two issues that don't occur when I use DetachedStateField=true. > (According to the user guide OpenJPA should function just as well without > one except that it may be less efficient. "OpenJPA can take advantage of a > detached state field to make the attach process more efficient. This field > is added by the enhancer and is not visible to your application.") > > > Issue 1: > When I add a new entity to a List of a detached (but not Serialized) entity > and then merge, OpenJPA throws: > > org.apache.openjpa.persistence.InvalidStateException: The context has been > closed. The stack trace at which the context was closed is held in the > embedded exception. > FailedObject: java.lang.IllegalStateException > at > org.apache.openjpa.kernel.BrokerImpl.assertOpen(BrokerImpl.java:4615) > ....... > > We don't experience this as a problem because we always Serialize an entity > before adjusting it!!! > > > Issue 2: > We have an object graph of four entities with autogenerated Id columns: > > Event (OneToMany bidirectional) Activity (OneToMany) ProductOrderLine > (OneToOne) StringI18N > > All relations are FetchType.EAGER and Cascade.ALL. > > When I add a new Activity (with one new ProductOrderLine with one new > StringI18N) to an existing Event and then merge the Event, OpenJPA tries to > insert a null value into the StringI18N Id column. This seems to be only > detected on transaction commit. > > This problem does not occur when: > > - I make the Event - Activity relation unidirectional, i.e. > Activity does not know it's parent Event. > > - The Event is new as well. > > - (workaround) I first add the new Activity to the Event but with > no ProductOrderLines, then merge the Event, then add the ProductOrderLine to > the Activity in the and merge the Event again. > > Are these known issues? What is the best way for me to go? Should I do my > workaround or should I try to use a detached state field? > Shall I report this to JIRA? I have a test case which shows these issues. > > > Regards, > > Henno Vermeulen > Huize Molenaar > > --0016361e89d406d95104a0cd7db1--