openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daryl Stultz <da...@6degrees.com>
Subject SingleFieldManager crash
Date Mon, 21 Sep 2009 16:37:38 GMT
I've spent a great amount of time trying to solve the condition that results
in this:
<openjpa-1.2.1-r752877:753278 nonfatal user error>
org.apache.openjpa.persistence.InvalidStateException: Encountered unmanaged
object in persistent field "model.A.b" 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: model.B-892
        at
org.apache.openjpa.kernel.SingleFieldManager.preFlushPC(SingleFieldManager.java:754)
        at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:594)
        at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:562)
        at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:478)

Note that A.b is not CascadeType.PERSIST and a.b is not new. I have found
that I can reproduce the stack trace like so (though I don't know if it's
the same condition as the original failure):

EntityManagerFactory factory = getEntityManagerFactory();
EntityManager em1 = factory.createEntityManager();
B b = em1.find(B, 1);
//em.close();
EntityManager em2 = factory.createEntityManager();
em2.getTransaction().begin();
A a = new A();
a.setB(b);
em2.persist(a);
em2.getTransaction().commit();

Uncomment em.close() and it works, so em2 has determined that "b" is not
detached, but no sm can be found. I would like to know if this is a bug. If
it is not a bug, I'd like to request that the exception contain better
information directing me to the problem.

Thank you.

-- 
Daryl Stultz
_____________________________________
6 Degrees Software and Consulting, Inc.
http://www.6degrees.com
mailto:daryl@6degrees.com

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