[DDC-2033] Merge with multiple Associations to the same Entity Created: 17/Sep/12  Updated: 23/Jan/13  Resolved: 23/Jan/13

Status: Closed
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Major
Reporter: sören jahns Assignee: Marco Pivetta
Resolution: Duplicate Votes: 1
Labels: merge
Environment:

Symfony 2.1.1, Ubuntu, PHP 5.3.5


Attachments: File Group.php     File User.php    

 Description   

Let's say we have 2 Entities. User and Group and there's a ManyToMany Assocication and an additional ManyToOne (User as owning side and no inverse).

So a User can have as many Groups as he likes and one another with the ManyToOne Association which can be also in the ManyToMany Collection. (Could be the MainGroup or something)

I create a User and add a Group(already in DB) and set the same as the ManyToOne and Merge it. Everything works fine as long as the Group in ManyToOne Association is not in the ManyToMany.

If I var_dump the merged entity i can already see that one association is empty.

It looks like doctrine is writing just one association of that Group preferring which one comes first. So if i change the position of the properties in the class the written association changes, but doctrine never writes both.

The reason why I use merge is that I normally store the entity in the session and merge and flush it in another request. But this also happens in the same Request.

In the UnitofWork at Line 2050 and 2053 are the responsible doMerge Calls for as CascadeMerge Tagged Associations. If Doctrine gets there in the first place the doMerge for the Group is running through. In the Second call when the Group is again associated with the user the doMerge already exits at line 1658. That's ok but I think there's something missing so doctrine isn't creating the association.

The Mentioned Entites are attached



 Comments   
Comment by Marco Pivetta [ 23/Jan/13 ]

Duplicate of DDC-1942

Generated at Mon Sep 01 21:40:03 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.