actually don't worry it seems to be working now.
i was disposing the entitymanager like this:
public void dispose(@Disposes @Any EntityManager entityManager) {
if (entityManager.isOpen()) {
entityManager.close();
}
}
whereas i needed to do this
public void disposeFile(@Disposes @Default @File EntityManager
entityManager) {
if (entityManager.isOpen()) {
entityManager.close();
}
}
public void disposeOperator(@Disposes @Operator EntityManager
entityManager) {
if (entityManager.isOpen()) {
entityManager.close();
}
}
On 14/03/2018 20:13, Matthew Broadhead wrote:
Hi,
OpenJPA 2.4.2, TomEE 7.0.3
since changing to multiple persistence units in the persistence.xml i
now get this message when trying to merge an @Entity
<openjpa-2.4.2-r422266:1777108 fatal user error>
org.apache.openjpa.persistence.InvalidStateException: Encountered
unmanaged object "uk.me.kissy.file.entities.jpa.Category-3" in life
cycle state unmanaged while cascading persistence via field
"uk.me.kissy.file.entities.jpa.File.category" 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().
FailedObject: uk.me.kissy.file.entities.jpa.Category-3
at
org.apache.openjpa.kernel.SingleFieldManager.preFlushPC(SingleFieldManager.java:786)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:621)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:589)
at
org.apache.openjpa.kernel.SingleFieldManager.preFlush(SingleFieldManager.java:510)
at
org.apache.openjpa.kernel.StateManagerImpl.preFlush(StateManagerImpl.java:3055)
at
org.apache.openjpa.kernel.PDirtyState.beforeFlush(PDirtyState.java:39)
at
org.apache.openjpa.kernel.StateManagerImpl.beforeFlush(StateManagerImpl.java:1072)
it seems like it is trying to persist an entity which should already
exist and be connected?