You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Daryl Stultz <da...@6degrees.com> on 2009/08/25 14:12:50 UTC

SingleFieldManager throwing error

Hi all,

I'm getting this error:

org.apache.openjpa.persistence.InvalidStateException: Encountered unmanaged
object in persistent field "blah.model.MyEntity.anotherEntity" 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: blah.model.AnotherEntity-1981
       at
org.apache.openjpa.kernel.SingleFieldManager.preFlushPC(SingleFieldManager.java:754)
       at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:594)

SingleFieldManager.preFlushPC looks like this, with the last line throwing
my exception:

        OpenJPAStateManager sm;


        *if* (vmd.getCascadePersist() == ValueMetaData.*CASCADE_NONE*) {

            *if* (!_broker.isDetachedNew() && _broker.isDetached(obj))

                *return*; // allow but ignore


            sm = _broker.getStateManager(obj);

            *if* (sm == *null* || !sm.isPersistent())

                *throw* *new* InvalidStateException(

                    *_loc*.get("cant-cascade-persist", vmd))

                    .setFailedObject(obj);


I can't reproduce the problem, so I don't know if sm is null or sm is not
persistent. I have 2 questions that are maybe the same: what condition leads
to sm being null or not persistent and what exactly is an "unmanaged"
object?

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