I have a document with several collections referencing documents in other collections.
Doctrine ODM seems to have issues with ArrayCollections and realizing that elements are being taken out. I call ArrayCollection->clear() on those collections but when calculating the changeset Doctrine does not realize that some were deleted.
My scenario is following: I have a REST API. On the API I use Doctrine ODM as data backend.
Now when I get a request to update an object, I get the passed ID of the object, and populate all the fields.
However with collections I call clear() on the collection and then re-add all passed elements. This might not be a very elegant solution, but I don't have to worry about added / changed / deleted items. I pretty much just set a new collection.
However, when persisting this document, Doctrine does not seem to notice that I cleared the collection. It just adds all the objects I added to the collection. Therefore I have a lot of duplicate items in my collection.