diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java index 66d1330ad..1a1a5d7b1 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataSerializer.java @@ -1012,7 +1012,10 @@ public class AnnotationPersistenceMetaDataSerializer if (vmd.getCascadeRefresh() == ValueMetaData.CASCADE_IMMEDIATE) { cascades.add(CascadeType.REFRESH); } - if (cascades.size() == 4) // ALL + if (vmd.getCascadeDetach() == ValueMetaData.CASCADE_IMMEDIATE) { + cascades.add(CascadeType.CLEAR); + } + if (cascades.size() == 5) // ALL { cascades.clear(); cascades.add(CascadeType.ALL); diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java index 30c360ebe..92a23aad7 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/EntityManagerImpl.java @@ -1475,6 +1475,7 @@ public class EntityManagerImpl } public void clear(Object entity) { + assertNotCloseInvoked(); _broker.detach(entity, this); }