many-to-many
Symfony2-Doctrine: ManyToMany relation is not saved to database
Your Category entity is the inverse side of the relationship. Try changing addItems to look like this: public function addItem(\Ako\StoreBundle\Entity\Item $item) { $item->addCategory($this); $this->items[] = $item; } Note that I changed your plural names to singular, since you’re dealing with single entities, not collections.
MongoDB Many-to-Many Association
Depending on your query needs you can put everything in the user document: {name:”Joe” ,roles:[“Admin”,”User”,”Engineer”] } To get all the Engineers, use: db.things.find( { roles : “Engineer” } ); If you want to maintain the roles in separate documents then you can include the document’s _id in the roles array instead of the name: {name:”Joe” … Read more