Uploaded image for project: 'Doctrine 2 - ORM'
  1. Doctrine 2 - ORM
  2. DDC-1879

Orphans are neither nulled nor removed when merging a graph of detached entities


    • Type: Bug
    • Status: Awaiting Feedback
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.2
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:
    • Environment:
      Doctrine 2.2.2
      PHP 5.3.10 with Suhosin-Patch
      mysql Ver 14.14 Distrib 5.5.15, for osx10.7
      Mac OS X 10.7 Lion


      When merging a graph of detached entities, the created entitied are created and the updated entities are updated but the non-present entities (which exist in the database but are not in the graph) are neither removed nor have them their association column nullified.

      Example :

      In my code I have 2 entities : Parent and Child. There is a OneToMany(cascade=


      , orphanRemoval=true) relation defined in Parent.

      In my database I have a Parent row with an id of 1, which has 3 Children with ids 1,2,3.

      When I write the following code, I expect the Parent with id 1 and the Child with id 2 to be updated, a new Child to be created and the Child with id 1 and 3 to be deleted.

      $parent = new Parent(); $parent->id = 1  // detached entity
      $existing_child = new Child(); $child->id = 2 // detached entity
      $new_child = new Child(); // new entity

      The objects I expect to be created and updated have the correct behaviour but the old children are not touched, they are still present in the database.



          • Assignee:
            beberlei Benjamin Eberlei
            systho Philippe Van Eerdenbrugghe
          • Votes:
            0 Vote for this issue
            2 Start watching this issue


            • Created: