In case it helps I set a breakpoint in UnitOfWorkImpl which is reached at [1] and the call to performRemove(Object toBeDeleted = `B` class instance) that throws the exception is called from cascadePerformRemoveIfRequired(). The `B` class instances have already been removed by previous calls. For reference, I'm debugging the EE TCK test with EclipseLink master branch sources. So we must be trying to cascade the remove to all visitedobjects [2] which includes `A` and `B`.
Hope this helps explain the problem we see with the described EE TCK test.
Scott
[1]
performRemove:3729, UnitOfWorkImpl (org.eclipse.persistence.internal.sessions) [2]
cascadePerformRemoveIfRequired:478, CollectionMapping (org.eclipse.persistence.mappings)
cascadePerformRemove:2631, ObjectBuilder (org.eclipse.persistence.internal.descriptors)
performRemove:3745, UnitOfWorkImpl (org.eclipse.persistence.internal.sessions) [1]
remove:677, EntityManagerImpl (org.eclipse.persistence.internal.jpa)
cascadeAllMXMTest4:310, Client (ee.jakarta.tck.persistence.core.entitytest.cascadeall.manyXmany)
[2] visitedObjects = {java.util.IdentityHashMap@14148} size = 2
{ee.jakarta.tck.persistence.core.entitytest.cascadeall.manyXmany.B@14129} -> {ee.jakarta.tck.persistence.core.entitytest.cascadeall.manyXmany.B@14129}
{ee.jakarta.tck.persistence.core.entitytest.cascadeall.manyXmany.A@14147} -> {ee.jakarta.tck.persistence.core.entitytest.cascadeall.manyXmany.A@14147}