The current technique used to queue operations in optimistic transactions is flawed: it queues operations *per collection* and does not honour the order of operations between different collections. If I have an optimistic transaction which does the following:
(given: two objects with collection properties, one object of element type)
The outcome after commit depends on the order in which the collections are processed.
A: add(element), remove(element), add(element)
B: add(element), remove(element)
With relationship management, element.owner would now be null; if B is processed first, it would be A. If everything was processed in order, it would be A (i.e. A would be correct / expected).
Please see the linked forum thread for further details. I've opened this issue so we do not forget to include a fix for this in DN 3.2.