DDC-2033: Merge with multiple Associations to the same Entity #2711

Closed
doctrinebot opened this Issue Sep 17, 2012 · 2 comments

2 participants

@doctrinebot

Jira issue originally created by user soeren.j:

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

@doctrinebot

Comment created by @ocramius:

Duplicate of DDC-1942

@doctrinebot

Issue was closed with resolution "Duplicate"

@Ocramius Ocramius was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment