Hi Folks,
I'm getting this exception, sporadically, non-reproducable.
Unmanaged object in persistent field
"com.su3analytics.crawler.model.GlobalFrontier.host" 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: com.su3analytics.crawler.model.Host-1
at
org.apache.openjpa.kernel.SingleFieldManager.preFlushPC(SingleFieldManager.java:767)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:607)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:575)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:491)
I've tried alternating between runtime (agent) and compile time
enhancement, and I get the error in both instances.
I am not setting the property: openjpa.RuntimeUnenhancedClasses
My code is loading an existing persisted object, and creating a new
object with the existing object as a field. Effectively:
ClientSeed cs = null;
{
EntityManager em =
JPA.getEntityManagerFactory().createEntityManager();
cs = em.find(ClientSeed.class, 1);
em.close();
}
// then later, on another thread
{
EntityManager em =
JPA.getEntityManagerFactory().createEntityManager();
em.getTransaction().begin();
GlobalFrontier frontier = new GlobalFrontier();
frontier.setHost(cs.getHost());
new GlobalFrontierDao(em).add(frontier);
em.getTransaction().commit();
}
The exception is only sporadic though.
Rgs
Joel