[FLOW3-general] Question to Bidirectional ManyToMany Relations with FLOW3 and CouchDB
Thomas Kirst
thomps at live.de
Thu Sep 22 11:00:02 CEST 2011
Dear all,
I'm trying to use CouchDB as Persistence Backend. But strangewise
bidirectional ManyToMany relations seem to not work as expected.
In my example I have got 'Teams' and 'Employees'. A team has several
members (=employees) and an employee is in one or more teams.
My models look like this:
[Model Employee]
class Employee {
/**
* Teams an employee is a member of
* @var
\Doctrine\Common\Collections\ArrayCollection<\IBM\IBMDB\Domain\Model\Team>
* @ManyToMany(inversedBy="members")
*/
protected $teams;
...
}
[Model Team]
class Team {
/**
* Team members
* @var
\Doctrine\Common\Collections\ArrayCollection<\IBM\IBMDB\Domain\Model\Employee>
* @ManyToMany(mappedBy="teams")
*/
protected $members;
...
}
---
When I now add one team to an employee it shows up in the database
record (property 'teams').
---
"classname": "IBM\\IBMDB\\Domain\\Model\\Employee",
"properties": {
...
"teams": {
"multivalue": true,
"value": [
{
"type": "IBM\\IBMDB\\Domain\\Model\\Team",
"index": 0,
"value": {
"identifier": "1b31c104-c9e0-4c5a-980e-183d848d1f16"
}
}
],
"type": "Doctrine\\Common\\Collections\\ArrayCollection"
},
...
But on the other side the relation from the team to the employee is not met.
"classname": "IBM\\IBMDB\\Domain\\Model\\Team",
"properties": {
...
"members": {
"multivalue": true,
"value": [
],
"type": "Doctrine\\Common\\Collections\\ArrayCollection"
},
...
As you can see the 'ArrayCollection' is empty and it seems like the
'reverse way' does not work.
Is there anything I missed in the method annotations? With MySQL the
bidirectional way works well.
Any ideas?
Thanks,
Thomas
More information about the FLOW3-general
mailing list