Hi Daryl, I get that exact error if one of my fields in my main entity has a reference to a child entity and the child is null. For example if I have an Address entity that contains a City entity and for some reason my City entity is null, then when I try to persist the Address entity, I'll get this error. It only seems to happen when I have the child entity cascade set to REFRESH. Took me days to work this one out but eventually tracked it down.
Hth Chris -----Original Message----- From: Daryl Stultz [mailto:da...@6degrees.com] Sent: Thursday, 20 August 2009 3:02 AM To: OpenJPA User List Subject: Encountered unmanaged object Hello, I'm looking for any clues to help troubleshoot the following error: Encountered unmanaged object in persistent field > "blah.model.MyEntity.myPropA" 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. It is happening very occasionally on a production system (Tomcat). I can't reproduce it. Here it is "myPropA" but it happened on "myPropB" as well. In both cases the objects of A and B were in the database already and not modified as part of the transaction. Anyone have any idea what could cause the properties to become "unmanaged"? I have to assume they were managed at some point since they were retrieved from the database via an entity manager (and the system is working largely as expected). I could set the cascade to PERSIST, but I don't need it and I don't know what it will do - maybe it will try to reinsert a copy of the object already in the database. Thanks. OpenJPA 1.2.1 -- Daryl Stultz _____________________________________ 6 Degrees Software and Consulting, Inc. http://www.6degrees.com mailto:da...@6degrees.com