Return-Path: X-Original-To: apmail-openjpa-users-archive@minotaur.apache.org Delivered-To: apmail-openjpa-users-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8B5A9103DE for ; Wed, 30 Apr 2014 21:32:39 +0000 (UTC) Received: (qmail 98251 invoked by uid 500); 30 Apr 2014 21:32:38 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 98205 invoked by uid 500); 30 Apr 2014 21:32:38 -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 Delivered-To: moderator for users@openjpa.apache.org Received: (qmail 1170 invoked by uid 99); 30 Apr 2014 20:43:40 -0000 X-ASF-Spam-Status: No, hits=1.3 required=5.0 tests=SPF_PASS,URI_HEX X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Date: Wed, 30 Apr 2014 13:42:35 -0700 (PDT) From: john To: users@openjpa.apache.org Message-ID: <1398890555027-7586298.post@n2.nabble.com> Subject: CheckDatabaseForCascadePersistToDetachedEntity=true in OSGi MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi My setup is - servicemix 5.0.0, openjpa 2.2.2, Mysql 5.5 database. I have 4 bundles, model-persistence, catalogs-persistence, models and catalogs. The 2 persistence bundles each have a persistence unit. The model-persistence bundle provides an OSGi service to save a model which is defined in in the models bundle. The catalogs-persistence provide a readonly get services which gets catalogs which are referenced by the model. When I try save a model which has a reference to one of the readonly catalogs (which I don't want to update) and which I get through the catalogs-persistence service (so the model-persistence is handling an object from another persistence unit) 15:09:53,324 | DEBUG | ectronica/create | ServiceRecipe | 7 - org.apache.aries.blueprint.core - 1.4.0 | Method entry: getService, args org.apache.karaf.jndi.KarafInitialContextFactory@2cf5e0f0 15:09:53,339 | DEBUG | ectronica/create | context | 199 - org.apache.aries.jpa.container.context - 1.0.1 | Created a new persistence context org.apache.aries.jpa.container.impl.EntityManagerWrapper@7933da2e for transaction [Xid:globalId=10ffffffe51effffffb4451006f72672e6170616368652e61726965732e7472616e73616374696f6e0000000000000000000000000000,length=64,branchId=0000000000000000000000000000000000000000000000000000000000000000,length=64]. 15:09:53,512 | WARN | ectronica/create | Transaction | 230 - org.apache.aries.transaction.manager - 1.1.0 | Unexpected exception from beforeCompletion; transaction will roll back org.apache.openjpa.persistence.InvalidStateException: Encountered unmanaged object "catalog.Catalog-673" in life cycle state unmanaged while cascading persistence via field "model.Model.catalog" during flush. However, this field does not allow cascade persist. You cannot flush unmanaged objects or graphs that have persistent associations to unmanaged objects. Suggested actions: a) Set the cascade attribute for this field to CascadeType.PERSIST or CascadeType.ALL (JPA annotations) or "persist" or "all" (JPA orm.xml), b) enable cascade-persist globally, c) manually persist the related field value prior to flushing. d) if the reference belongs to another context, allow reference to it by setting StoreContext.setAllowReferenceToSiblingContext(). FailedObject: catalog.Catalog-673 at org.apache.openjpa.kernel.SingleFieldManager.preFlushPC(SingleFieldManager.java:786) at org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:621) at org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:589) at org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:505) at org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:3018) at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:44) at org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:1034) at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2122) at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2082) at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:2000) at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:527) at org.apache.geronimo.transaction.manager.TransactionImpl.beforeCompletion(TransactionImpl.java:511) at org.apache.geronimo.transaction.manager.TransactionImpl.beforePrepare(TransactionImpl.java:413) I was thinking that this is what the CheckDatabaseForCascadePersistToDetachedEntity=true property is so I added it to the persistence unit. model.Model But it doesn't change anything. Should this option remove the problem I am having? Should it work in OSGi? Are there any suggestions as to what I am doing wrong and if it is possible at all? Cheers John -- View this message in context: http://openjpa.208410.n2.nabble.com/CheckDatabaseForCascadePersistToDetachedEntity-true-in-OSGi-tp7586298.html Sent from the OpenJPA Users mailing list archive at Nabble.com.