[FLOW3-general] ManyToMany Association ("owningSide", "inversedSide")
Davide CD
dmichelangeli at hotmail.com
Wed May 16 16:05:51 CEST 2012
Hi!
I have two classes, User and Hotel which are connected with a ManyToMany relationship. These classes are partially described here (only properties and methods that are involved in the relationship).
http://pastebin.com/hheDCvdw
I use Extjs with FLOW3.
A Extjs Grid gives the possibility to assign to a hotel many users. Hotel is the Owningside of this relationship. I can add and remove users assigned to a specific hotel with no problems. Everything works fine.
The (big, for me) problem is the inverse side of the relation, when I try to assign many hotels to a user. I read in Doctrine Documentation that you MUST also update the owning side of the relationship (how ??). That's why I put that "for cycle" in the user's method "setHotels". Now, lets say that user 1 has no hotels assigned to it:
user1 -> - no hotels assigned to
Let's assigned to hotels to the user1, say, hotel1 and hotel2.
>From ExtJS, I send an array to a FLOW3 REST Controller with the two identities of hotel1 and hotel2.
user1 -> hotel1, hotel2
No problem here. Everything works fine. The hotels are correctly assigned to the user.
Now, I would like to remove hotel1 in order to have only hotel2 assigned to user1:
>From ExtJS, I send an array with the only the identity of hotel2.
user1 -> hotel2
And here is the big problem. I don't know how I can do it. I recieve errors like "DUPLICATE KEY Entry for ...." (.
In other words, I don't know how to avoid the duplicate entry. How can I test (should I ??) if an entry still exists in the association table?
Or this is the wrong approach?
Thank you very much in advance.
Davide
More information about the FLOW3-general
mailing list