openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Waruna Ranasinghe <waruna...@gmail.com>
Subject How to enable cascade-persistence globally
Date Tue, 19 Jun 2012 11:43:57 GMT
Hi all,

I would like to know whether I can set cascade-persistence globally through
the persistence.xml

I found that I set this in orm.xml, but it did not work. See the
configuration below
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
 http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" version="1.0">
   <persistence-unit-metadata>
     <persistence-unit-defaults>
       <cascade-persist/>
     </persistence-unit-defaults>
   </persistence-unit-metadata>
</entity-mappings>


The reason for me to set this property is that I get the following
exception which suggest me to set the  cascade-persistent property

[2012-06-19 17:01:34,177] ERROR
{org.apache.axis2.jaxws.WebServiceExceptionLogger} -  A
org.apache.openjpa.persistence.InvalidStateException throwable was caught.
The detail message is: atal user error>
org.apache.openjpa.persistence.InvalidStateException: Encountered unmanaged
object "org.apache.juddi.model.BusinessEntity@96ba55a" in life cycle state
unmanaged while cascading persistence via field
"org.apache.juddi.model.BusinessService.businessEntity" 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: org.apache.juddi.model.BusinessEntity@96ba55a
    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:2982)
    at org.apache.openjpa.kernel.PNewState.beforeFlush(PNewState.java:40)
    at
org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:1054)
    at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2112)
    at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2072)
    at
org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1990)
    at
org.apache.openjpa.kernel.LocalManagedRuntime.commit(LocalManagedRuntime.java:81)
    at org.apache.openjpa.kernel.BrokerImpl.commit(BrokerImpl.java:1514)
    at
org.apache.openjpa.kernel.DelegatingBroker.commit(DelegatingBroker.java:933)
    at
org.apache.openjpa.persistence.EntityManagerImpl.commit(EntityManagerImpl.java:570)
    at
org.apache.juddi.api.impl.UDDIPublicationImpl.saveService(UDDIPublicationImpl.java:539)


Thanks in advance,
Waruna



-- 
-----------------------------------------------------
Regards,
Waruna Ranasinghe

www.wso2.com - "Lean . Enterprise . Middleware"

blog: http://warunapw.blogspot.com
twitter: http://twitter.com/warunapww
http://lk.linkedin.com/in/waruna
www.facebook.com/waruna.ranasinghe

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message