Return-Path: Delivered-To: apmail-openjpa-dev-archive@www.apache.org Received: (qmail 18232 invoked from network); 15 Nov 2007 22:42:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Nov 2007 22:42:39 -0000 Received: (qmail 10883 invoked by uid 500); 15 Nov 2007 22:42:26 -0000 Delivered-To: apmail-openjpa-dev-archive@openjpa.apache.org Received: (qmail 10736 invoked by uid 500); 15 Nov 2007 22:42:26 -0000 Mailing-List: contact dev-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openjpa.apache.org Delivered-To: mailing list dev@openjpa.apache.org Received: (qmail 10726 invoked by uid 99); 15 Nov 2007 22:42:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Nov 2007 14:42:25 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ppoddar@bea.com designates 66.248.192.39 as permitted sender) Received: from [66.248.192.39] (HELO repmmg02.bea.com) (66.248.192.39) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 15 Nov 2007 22:42:15 +0000 Received: from repmmr02.bea.com (repmmr02.bea.com [10.160.30.72]) by repmmg02.bea.com (Switch-3.3.0/Switch-3.2.7) with ESMTP id lAFMg6G2026240 for ; Thu, 15 Nov 2007 14:42:06 -0800 Received: from repbex01.amer.bea.com (repbex01.bea.com [10.160.26.98]) by repmmr02.bea.com (Switch-3.3.0/Switch-3.2.7) with ESMTP id lAFMg5V4012292 for ; Thu, 15 Nov 2007 14:42:05 -0800 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: RE: @PostPersist woes Date: Thu, 15 Nov 2007 14:42:03 -0800 Message-ID: <3992B07C0590B548BB294D31768A1DA2A128D4@repbex01.amer.bea.com> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: @PostPersist woes Thread-Index: Acgn1rtXUla6AhzcSpq+PyypdtViQgAAVLZg References: <535E699A-DC3D-46AE-AF17-7652D0C59ABD@pobox.com> <3992B07C0590B548BB294D31768A1DA2A1287E@repbex01.amer.bea.com> <2730F200-F5BB-4BF9-B84E-99B3A129574F@pobox.com> <3992B07C0590B548BB294D31768A1DA2A1288C@repbex01.amer.bea.com> From: "Pinaki Poddar" To: x-BEA-PMX-Instructions: AV x-BEA-MM: Internal-To-External X-Virus-Checked: Checked by ClamAV on apache.org > > > If possible, try application set identity for InventoryItem, not the > provider. public class X { @Id @GeneratedValue private long id; // no setId() method; public class Y { @Id private long id; public void setId(long id) { this.id = id; } } X is using auto-assigned id, Y is using application id. It is the responsibility of the application developer to call Y.getId() with unique values before an instance being persisted. For A, it is the JPA provider who is responsible for doing the same 'under the hood'. will wait for your posting of InventoryItem class definition + @PostPersist code block + the invocation context. -----Original Message----- From: Geir Magnusson Jr. [mailto:geir@pobox.com] Sent: Thursday, November 15, 2007 1:52 PM To: dev@openjpa.apache.org Subject: Re: @PostPersist woes On Nov 15, 2007, at 4:45 PM, Pinaki Poddar wrote: > It is failing on an instance of InventoryItem.getId() -- is it itself > the argument of persist() or an instance navigable from it? This is where things get fun. InventoryItem is a baseclass of A and B and we're using Joined inheritance strategy. So yes, InventoryItem will be the arg to persist(). That said, see my next mail where I provide some detail... > > > If possible, try application set identity for InventoryItem, not the > provider. What does that mean? (I'm an openjpa newbie...) geir > > > > -----Original Message----- > From: Geir Magnusson Jr. [mailto:geir@pobox.com] > Sent: Thursday, November 15, 2007 1:41 PM > To: dev@openjpa.apache.org > Subject: Re: @PostPersist woes > > > On Nov 15, 2007, at 4:34 PM, Pinaki Poddar wrote: > >>> persist() has in it a new, unmanaged entity. >> >> a) If persist(a) is failing on b, what is the cascade type specified >> on relation a.b? > > I'm not actually sure that it's failing on b. I guess I can try to > figure that out. I just know that when I change things so that I > have an unmanaged b, it fails. > >> >> b) what is the identity definition on b? >> c) if b is using auto-assigned GeneratedValue or its id is being set >> by application? >> >> -----Original Message----- >> From: Geir Magnusson Jr. [mailto:geir@pobox.com] >> Sent: Thursday, November 15, 2007 11:10 AM >> To: dev@openjpa.apache.org >> Subject: @PostPersist woes >> >> Woe is me :) >> >> I'm using @PostPersist to create some kind of machine-generated data >> for entities on insert, and I'm running into the following problem >> when an entity for which I called persist() has in it a new, >> unmanaged > >> entity. >> >> [junit-coverage] Caused by: > error> org.apache.openjpa.util.InvalidStateException: Detected >> reentrant flush. Make sure your flush-time instance callback methods >> or event listeners do not invoke any operations that require the in- >> progress flush to complete. >> [junit-coverage] at >> org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:1840) >> [junit-coverage] at >> org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:1615) >> [junit-coverage] at >> org >> .apache >> .openjpa >> .kernel.StateManagerImpl.assignObjectId(StateManagerImpl.java: >> 505) >> [junit-coverage] at >> org >> .apache >> .openjpa.kernel.StateManagerImpl.assignField(StateManagerImpl.java: >> 590) >> [junit-coverage] at >> org >> .apache >> .openjpa >> .kernel.StateManagerImpl.beforeAccessField(StateManagerImpl.java: >> 1451) >> [junit-coverage] at >> org >> .apache >> .openjpa >> .kernel.StateManagerImpl.accessingField(StateManagerImpl.java: >> 1434) >> [junit-coverage] at >> com.joost.model.InventoryItem.getId(InventoryItem.java) >> [junit-coverage] at >> com.joost.model.InventoryItem.initPublicIdIfNull(InventoryItem.java: >> 331) >> >> >> in InventoryItem, getId is the PK, and my read of the spec says that >> I am guaranteed to have it in @PostPersist. >> >> Bug? me doing something wrong? >> >> geir >> >> >> Notice: This email message, together with any attachments, may >> contain information of BEA Systems, Inc., its subsidiaries and >> affiliated entities, that may be confidential, proprietary, >> copyrighted and/or legally privileged, and is intended solely for >> the use of the individual or entity named in this message. If you are >> not the intended recipient, and have received this message in error, >> please immediately return this by email and then delete it. > > > Notice: This email message, together with any attachments, may > contain information of BEA Systems, Inc., its subsidiaries and > affiliated entities, that may be confidential, proprietary, > copyrighted and/or legally privileged, and is intended solely for the > use of the individual or entity named in this message. If you are not > the intended recipient, and have received this message in error, > please immediately return this by email and then delete it. Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it.