i am trying to create a oneToMany relationship. Since Doctrine only offers ManyToOne Unidirectional im using that. Somehow the validation of the mapping fails and I am not able to spot my mistake:
Validation Error:
[Mapping] FAIL - The entity-class 'Strego\TippBundle\Entity\BetRound' mapping is invalid: * The association Strego\TippBundle\Entity\BetRound#userStatus refers to the owning side field Strego\TippBundle\Entity\UserBetRoundStatus#betRound which does not exist.
My First Entity (BetRound):
<?php
namespace Strego\TippBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\Collection as Collection;
use Strego\AppBundle\Entity\Base as BaseEntity;
/**
* Strego\TippBundle\Entity\BetRound
*
* @ORM\Table()
* @ORM\Entity
*/
class BetRound extends BaseEntity {
//......
/**
*
* @var Collection
* @ORM\OneToMany(targetEntity="UserBetRoundStatus", mappedBy="betRound", cascade={"all"})
*/
protected $userStatus;
}
My related Entity(UserBetRoundStatus)
<?php
namespace Strego\TippBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Strego\AppBundle\Entity\Base as BaseEntity;
/**
* Strego\TippBundle\Entity\Game
*
* @ORM\Table
* @ORM\Entity
* @UniqueEntity(fields={"user", "betRound"}, message="Unique Entity Validator Fails for UserStatus", groups="unique")
*
*/
class UserBetRoundStatus extends BaseEntity {
// .....
/*
* @var BetRound
* @ORM\ManyToOne(targetEntity="BetRound", inversedBy="userStatus")
* @ORM\JoinColumn(name="betround_id", referencedColumnName="id", nullable=false)
* @Assert\NotNull()
*/
protected $betRound;
}