I am attempting to create a OneToMany relationship between two of my entities. One Customer
can be a member of many Club
s.
These are my entities:
class Club
{
/**
* @ORM\ManyToOne(targetEntity="Customer", inversedBy="clubs")
*/
private $customer;
class Customer
{
/**
* @var Club[]
*
* @ORM\OneToMany(targetEntity="Club", cascade={"persist"}, inversedBy="customer")
* @ORM\JoinTable(name="customer_club",
* joinColumns={@ORM\JoinColumn(name="customer_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="club_id", referencedColumnName="id", unique=true)}
* )
*/
private $clubs;
Rather than adding a field to the club
table, I have created a customer_club
table which looks like:
_________________________
| customer_id | club_id |
_________________________
| 1 | 16 |
| 1 | 90 |
| 1 | 72 |
_________________________
These relationship definitions are wrong because when I load my Symfony 3.4 application I get the following error:
[Creation Error] The annotation @ORM\OneToMany declared on property AppBundle\Entity\Customer::$clubs does not have a property named "inversedBy". Available properties: mappedBy, targetEntity, cascade, fetch, orphanRemoval, indexBy
What have I done wrong?