datanucleus-core icon indicating copy to clipboard operation
datanucleus-core copied to clipboard

Detaching an object graph with a Map and an overridden hashcode() in the map key fails when the key is being detached

Open andyjefferson opened this issue 8 years ago • 0 comments

Attached project demonstrates that PersistenceManager.detachCopy(Object) fails when the object graph has these properties:

  1. There is a loop
  2. The loop contains a Map key
  3. The Map key has hashcode() overridden

The reason detaching fails is that the instance added to the Map is still being detached (the fields are not set yet).

It is possible that this issue cannot be fixed due to the nature of the object graph, and the requirement of JDO to detach a copy. DN_FailingDetach.zip

Detaching the same object graph at the end of a transaction (i.e. in-place) works perfectly. The settings for this are: javax.jdo.option.DetachAllOnCommit=true javax.jdo.option.RetainValues=true

andyjefferson avatar Apr 11 '16 07:04 andyjefferson