Entity contains pseudo-attached ElementCollection map after detach ------------------------------------------------------------------
Key: OPENJPA-1919 URL: https://issues.apache.org/jira/browse/OPENJPA-1919 Project: OpenJPA Issue Type: Bug Components: kernel Affects Versions: 2.0.0 Reporter: Vermeulen When calling Map.put on a detached entity that has the map mapped with @ElementCollection, I get an InvalidStateException in BrokerImpl.assertOpen (see stacktrace below). Steps to reproduce: 1. Create a test entity with a Map-typed field: @ElementCollection(fetch = FetchType.EAGER) Map<String, String> strings = new HashMap<String, String>(); 2. persist/merge a new instance 3. Detach the instance 4. Call strings.put("a", "b") on the detached instance This looks just like the older bug OPENJPA-733 which was with Embeddables. Tested with these settings in persistence.xml: <property name="openjpa.jdbc.MappingDefaults" value="ForeignKeyDeleteAction=restrict, JoinForeignKeyDeleteAction=restrict" /> <property name="openjpa.DetachState" value="fetch-groups" /> <property name="openjpa.DetachState" value="fgs(DetachedStateField=false)" /> <!-- Automatically detach on commit! --> <property name="openjpa.AutoDetach" value="commit" /> Stacktrace: <openjpa-2.0.0-r422266:935683 fatal user error> org.apache.openjpa.persistence.InvalidStateException: The context has been closed. The stack trace at which the context was closed is available if Runtime=TRACE logging is enabled. at org.apache.openjpa.kernel.BrokerImpl.assertOpen(BrokerImpl.java:4573) at org.apache.openjpa.kernel.BrokerImpl.beginOperation(BrokerImpl.java:1895) at org.apache.openjpa.kernel.BrokerImpl.isActive(BrokerImpl.java:1865) at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1690) at org.apache.openjpa.kernel.StateManagerImpl.dirty(StateManagerImpl.java:1628) at org.apache.openjpa.util.Proxies.dirty(Proxies.java:69) at org.apache.openjpa.util.ProxyMaps.beforePut(ProxyMaps.java:83) at org.apache.openjpa.util.java$util$HashMap$proxy.put(Unknown Source) at MinimalExampleTest.mergeExample(MinimalExampleTest.java:33) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41) at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) at org.junit.runners.ParentRunner.run(ParentRunner.java:220) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.