> That entity has a field associated with another entity. Both these entities belong to different persistence units. You can't persist a relationship from an Entity to another Entity that belongs in a different persistence units. An EntityManager will only operate against Entities that are a part of it's persistence unit definition. Do you truly have two different persistence units, or do you just have two different EntityManagers?
On Mon, Oct 21, 2013 at 11:50 AM, Akash Gunjal <akgun...@in.ibm.com> wrote: > Hi, > > I am trying to persist an entity into the database. That entity has a field > associated with another entity. Both these entities belong to different > persistence units. When trying to persist the entity I get the below error. > > > Invalid parameter - Encountered unmanaged object > "com.ibm.powersc.ts.policies.vlan.persistence.VLANPolicy@40004000" in life > cycle state unmanaged while cascading persistence via field > "com.ibm.sc.core.persistence.Zone.policies<element:class > com.ibm.sc.core.persistence.Policy>" 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(). > > > I tried to give cascade.All option to the field having entity reference, > then I get an error message "This entity is not managed by this context". > > Regards, > Akash > > -- *Rick Curtis*