openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Curtis <curti...@gmail.com>
Subject Re: How to enable cascade-persistence globally
Date Wed, 20 Jun 2012 13:54:13 GMT
Waruna -

Can you try setting this property ?

openjpa.Compatibility=CheckDatabaseForCascadePersistToDetachedEntity=false

Thanks,
Rick

On Wed, Jun 20, 2012 at 12:08 AM, Waruna Ranasinghe <warunapww@gmail.com>wrote:

> Hi Rick,
>
> I tried setting the CascadeType.ALL, then I get the following exception.
> Does this mean that the client application is trying to create two objects
> with the same oid?
>
> The thing is this code works fine with OpenJPA 2.0.0 but if we use OpenJPA
> 2.2.0, then these errors occur.
>
> Caused by: <openjpa-2.2.0-wso2v1-r128166:129108 nonfatal store error>
> org.apache.openjpa.persistence.EntityExistsException: An object of type
> "org.apache.juddi.model.BusinessEntity" with oid
> "uddi:juddi.apache.org:6a6294ef-90c8-43b1-b5f6-8200667f078d"
> already exists in this context; another cannot be persisted.
> FailedObject: org.apache.juddi.model.BusinessEntity@211bfe02
>    at
>
> org.apache.openjpa.kernel.BrokerImpl.checkForDuplicateId(BrokerImpl.java:5075)
>    at
> org.apache.openjpa.kernel.BrokerImpl.persistInternal(BrokerImpl.java:2651)
>    at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2571)
>    at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2554)
>    at
>
> org.apache.openjpa.kernel.SingleFieldManager.preFlushPC(SingleFieldManager.java:800)
>     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)
>
>
> Thanks,
> Waruna
> On 19 June 2012 19:40, Rick Curtis <curtisr7@gmail.com> wrote:
>
> > Waruna -
> >
> > For giggles, can you try to manually set the field in question(erro) to
> > CascadeType.ALL? This might help us narrow down where the real problem
> is.
> >
> > Thanks,
> > Rick
> >
> > On Tue, Jun 19, 2012 at 6:43 AM, Waruna Ranasinghe <warunapww@gmail.com
> > >wrote:
> >
> > > 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
> > >
> >
> >
> >
> > --
> > *Rick Curtis*
> >
>
>
>
> --
> -----------------------------------------------------
> 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
>



-- 
*Rick Curtis*

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