Return-Path: Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: (qmail 81203 invoked from network); 30 Jan 2011 17:31:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Jan 2011 17:31:30 -0000 Received: (qmail 41432 invoked by uid 500); 30 Jan 2011 17:31:30 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 41200 invoked by uid 500); 30 Jan 2011 17:31:28 -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 41192 invoked by uid 99); 30 Jan 2011 17:31:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Jan 2011 17:31:28 +0000 X-ASF-Spam-Status: No, hits=2.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [82.132.130.151] (HELO mail.o2.co.uk) (82.132.130.151) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 30 Jan 2011 17:31:20 +0000 Received: from [192.168.1.68] (188.222.122.17) by mail.o2.co.uk (8.5.119.05) (authenticated as joel.halbert8909@o2.co.uk) id 4C9F76EE206AE647 for users@openjpa.apache.org; Sun, 30 Jan 2011 17:30:59 +0000 Subject: Re: Unmanaged object in persistent fie - exception From: Joel Halbert To: users@openjpa.apache.org In-Reply-To: <1296408196.8799.14.camel@bohr> References: <1296408196.8799.14.camel@bohr> Content-Type: text/plain; charset="UTF-8" Date: Sun, 30 Jan 2011 17:30:57 +0000 Message-ID: <1296408657.8799.16.camel@bohr> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org It looks like someone else describes the same problem: http://openjpa.208410.n2.nabble.com/PC-object-losing-state-td4249977.html I should say I'm using 2.0.1 Could this be a known bug? Rgs, Joel On Sun, 2011-01-30 at 17:23 +0000, Joel Halbert wrote: > Hi Folks, > > I'm getting this exception, sporadically, non-reproducable. > > > Unmanaged object in persistent field "com.su3analytics.crawler.model.GlobalFrontier.host" during flush. However, this field does not allow cascade persist. Set the cascade attribute for this field to CascadeType.PERSIST or CascadeType.ALL (JPA annotations) or "persist" or "all" (JPA orm.xml), or enable cascade-persist globally, or manually persist the related field value prior to flushing. You cannot flush unmanaged objects or graphs that have persistent associations to unmanaged objects. > FailedObject: com.su3analytics.crawler.model.Host-1 > at org.apache.openjpa.kernel.SingleFieldManager.preFlushPC(SingleFieldManager.java:767) > at org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:607) > at org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:575) > at org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:491) > > > I've tried alternating between runtime (agent) and compile time > enhancement, and I get the error in both instances. > > I am not setting the property: openjpa.RuntimeUnenhancedClasses > > My code is loading an existing persisted object, and creating a new > object with the existing object as a field. Effectively: > > > ClientSeed cs = null; > { > EntityManager em = JPA.getEntityManagerFactory().createEntityManager(); > cs = em.find(ClientSeed.class, 1); > em.close(); > } > > // then later, on another thread > > { > EntityManager em = JPA.getEntityManagerFactory().createEntityManager(); > em.getTransaction().begin(); > GlobalFrontier frontier = new GlobalFrontier(); > frontier.setHost(cs.getHost()); > new GlobalFrontierDao(em).add(frontier); > em.getTransaction().commit(); > } > > The exception is only sporadic though. > > Rgs > Joel >