[FLOW3-general] Self referencing M:N Relation
Carsten Bleicker
carsten at bleicker.de
Fri Mar 1 18:42:56 CET 2013
try something like this?
/**
* @var \Doctrine\Common\Collections\Collection<\WS\Rico\Domain\Model\Company>
* @ORM\ManyToMany
* @ORM\JoinTable(name="ws_rico_domain_model_provider_relations",
* joinColumns={@ORM\JoinColumn(name="parent", referencedColumnName="persistence_object_identifier")},
* inverseJoinColumns={@ORM\JoinColumn(name="child", referencedColumnName="persistence_object_identifier")}
* )
*/
Am 01.03.2013 um 18:38 schrieb Cornel Widmer:
> Sorry folks
>
> I really try hard to get over the starting problems. Most of my problems are ORM related ... so this one either.
>
> I need a self referencing Many-to-Many relation. In my model i have the model company, with the property customers and providers. Each Company can have multiple Customers (Company-Model) and so every Company can have multiple Providers (Company-Model).
>
> First try...
>
> /**
> * @var \Doctrine\Common\Collections\ArrayCollection<\WS\Rico\Domain\Model\Company>
> * @ORM\ManyToMany(mappedBy="companyCustomers")
> * @ORM\Column(nullable=true)
> */
> protected $companyProviders;
>
> /**
> * @var \Doctrine\Common\Collections\ArrayCollection<\WS\Rico\Domain\Model\Company>
> * @ORM\ManyToMany(inversedBy="companyProviders")
> * @ORM\Column(nullable=true)
> */
> protected $companyCustomers;
>
>
> The first update with doctrine:update was successfull, but something is wrong. No associations are stored in the database. When I try to update the Database again I'm getting errors.
>
> How to do that?
>
> I also tried to adopt the example of doctrine ... but not with usable results.
> http://docs.doctrine-project.org/en/2.0.x/reference/association-mapping.html#many-to-many-self-referencing
>
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
More information about the FLOW3-general
mailing list