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

Cascading "refresh" does not work on lazy loaded associations


    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Invalid
    • Affects Version/s: 2.1.7
    • Fix Version/s: None
    • Component/s: ORM
    • Security Level: All
    • Labels:


      If the cascade option for an association includes the "refresh" keyword, the associated entites are only refreshed, if the collection is not lazy loaded.

      The problem is that first the "parent" entity is reloaded, so the associations PersistentCollection is replaced with a new one that has not been initialized yet. And then in cascadeRefresh, the code explicitly avoids initializing that collection, so there will never be any entities in the wrapped ArrayCollection that the operation may cascade to.

      I can see at least two possible solutions for this problem. One would be to swap the order of the operations, so that the cascading happens first. This would cascade based on the current object model state (pre-refresh), so entities that had been detached would not be refreshed.

      The other would be to remember which collections had already been loaded, and to initialize the corresponding new collections before performing the cascading. That would cascade based on the refreshed state, so in this case, entities that had been newly attached would not be refreshed.

      My current use-case would work with the first one, but I guess there will be some use-cases that would require the second one... :-/

        Issue Links


          sbeining Sascha Beining created issue -
          ocramius Marco Pivetta made changes -
          Field Original Value New Value
          Status Open [ 1 ] Awaiting Feedback [ 10000 ]
          Anonymous made changes -
          Status Awaiting Feedback [ 10000 ] In Progress [ 3 ]
          asm89 Alexander made changes -
          Status In Progress [ 3 ] Awaiting Feedback [ 10000 ]
          beberlei Benjamin Eberlei made changes -
          Status Awaiting Feedback [ 10000 ] In Progress [ 3 ]
          beberlei Benjamin Eberlei made changes -
          Status In Progress [ 3 ] Resolved [ 5 ]
          Resolution Invalid [ 6 ]
          beberlei Benjamin Eberlei made changes -
          Link This issue duplicates DDC-2143 [ DDC-2143 ]
          MartijnD Martijn Dwars made changes -
          Comment [ Was this issue actually resolved back in '13? I'm using 2.4.6 and experiencing exactly the same issue. Should I create an issue on this JIRA? ]


            • Assignee:
              beberlei Benjamin Eberlei
              sbeining Sascha Beining
            • Votes:
              0 Vote for this issue
              5 Start watching this issue


              • Created: