On Wed, Sep 16, 2009 at 6:44 PM, C N Davies <[email protected]> wrote:
> I know you said that your key is valid, but have you logged the complete > entity all the way though the cascaded entities? I created a test to expose this. Here's a sanitized version: EntityManager em = getEm(); A a = em.find(A.class, 1); B b = em.find(B.class, 2); assertTrue(a.getB() == b); // b is a member of a // null b prop of a and delete b outside of JPA jumpThroughHoops(); em.getTransaction().begin(); C c = new C(); c.setA(a); em.persist(c); em.getTransaction().commit(); // success! em.refresh(c); // fails here c.a and a.b are set to CascadeType.REFRESH. Note that the commit is successful (the persist does not discover that b is not there). But the em.refresh(c) fails with: <openjpa-1.2.1-r752877:753278 nonfatal store error> org.apache.openjpa.persistence.EntityNotFoundException: This operation failed for some instances. See the nested exceptions array for details. at org.apache.openjpa.kernel.BrokerImpl.throwNestedExceptions(BrokerImpl.java:2353) at org.apache.openjpa.kernel.BrokerImpl.refreshInternal(BrokerImpl.java:2882) at org.apache.openjpa.kernel.BrokerImpl.refresh(BrokerImpl.java:2775) at org.apache.openjpa.kernel.DelegatingBroker.refresh(DelegatingBroker.java:1078) at org.apache.openjpa.persistence.EntityManagerImpl.refresh(EntityManagerImpl.java:688) at ... Caused by: <openjpa-1.2.1-r752877:753278 nonfatal store error> org.apache.openjpa.persistence.EntityNotFoundException: The following instances do not exist in the data store: [16 [org.apache.openjpa.util.IntId]] at org.apache.openjpa.kernel.BrokerImpl.newObjectNotFoundException(BrokerImpl.java:4413) at org.apache.openjpa.kernel.BrokerImpl.refreshInternal(BrokerImpl.java:2847) ... 20 more Caused by: <openjpa-1.2.1-r752877:753278 nonfatal store error> org.apache.openjpa.persistence.EntityNotFoundException: The instance "16 [org.apache.openjpa.util.IntId]" does not exist in the data store. FailedObject: 16 [java.lang.Integer] at org.apache.openjpa.kernel.BrokerImpl.newObjectNotFoundException(BrokerImpl.java:4412) ... 21 more So it's interesting that it fails in a different way then yours, but in any case I'm not using REFRESH in my production code. -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:[email protected]
