title: Symfony2 - Association refers to the owning side which does not exist
body: <p>I'm trying to do mapping associations in symfony2 but I'm having some problems. Here's my code:</p>
  
  <p><em>OSC\UserBundle\Resources\doctrine\Child.orm.yml</em></p>
  
  <pre><code>OSC\UserBundle\Entity\Child:
      type: entity
      table: null
      repositoryClass: OSC\UserBundle\Entity\ChildRepository
      id:
          id:
              type: integer
              id: true
              generator:
                  strategy: AUTO
      fields:
          firstName:
              type: string
              length: 255
          lastName:
              type: string
              length: 255
          dateOfBirth:
              type: datetime
              column: dateOfBirth
          isPlayer:
              type: boolean
              default: false
          isCoach:
              type: boolean
              default: false
  
      ManyToOne:
          parent:
              targetEntity: User
              inversedBy: children
  
      lifecycleCallbacks: {  }
  </code></pre>
  
  <p><em>OSC\UserBundle\Entity\Child.php</em></p>
  
  <pre><code>&lt;?php
  
  namespace OSC\UserBundle\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * Child
   */
  class Child
  {
      /**
       * @var integer
       */
      private $id;
  
      /**
       * @var string
       */
      private $firstName;
  
      /**
       * @var string
       */
      private $lastName;
  
      /**
       * @var \DateTime
       */
      private $dateOfBirth;
  
  
       protected $isPlayer;
  
       protected $isCoach;
  
       protected $player;
  
      /**
       * Get id
       *
       * @return integer 
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set firstName
       *
       * @param string $firstName
       * @return Child
       */
      public function setFirstName($firstName)
      {
          $this-&gt;firstName = $firstName;
  
          return $this;
      }
  
      /**
       * Get firstName
       *
       * @return string 
       */
      public function getFirstName()
      {
          return $this-&gt;firstName;
      }
  
      /**
       * Set lastName
       *
       * @param string $lastName
       * @return Child
       */
      public function setLastName($lastName)
      {
          $this-&gt;lastName = $lastName;
  
          return $this;
      }
  
      /**
       * Get lastName
       *
       * @return string 
       */
      public function getLastName()
      {
          return $this-&gt;lastName;
      }
  
      /**
       * Set dateOfBirth
       *
       * @param \DateTime $dateOfBirth
       * @return Child
       */
      public function setDateOfBirth($dateOfBirth)
      {
          $this-&gt;dateOfBirth = $dateOfBirth;
  
          return $this;
      }
  
      /**
       * Get dateOfBirth
       *
       * @return \DateTime 
       */
      public function getDateOfBirth()
      {
          return $this-&gt;dateOfBirth;
      }
  
  
      /**
       * Set isPlayer
       *
       * @param boolean $isPlayer
       * @return Child
       */
      public function setIsPlayer($isPlayer)
      {
          $this-&gt;isPlayer = $isPlayer;
  
          return $this;
      }
  
      /**
       * Get isPlayer
       *
       * @return boolean 
       */
      public function getIsPlayer()
      {
          return $this-&gt;isPlayer;
      }
  
      /**
       * Set isCoach
       *
       * @param boolean $isCoach
       * @return Child
       */
      public function setIsCoach($isCoach)
      {
          $this-&gt;isCoach = $isCoach;
  
          return $this;
      }
  
      /**
       * Get isCoach
       *
       * @return boolean 
       */
      public function getIsCoach()
      {
          return $this-&gt;isCoach;
      }
  
  }
  </code></pre>
  
  <p><em>OSC\UserBundle\Entity\User.orm.yml</em></p>
  
  <pre><code>OSC\UserBundle\Entity\User:
      type: entity
      table: null
      repositoryClass: OSC\UserBundle\Entity\UserRepository
      fields:
          id:
              type: integer
              id: true
              generator:
                  strategy: AUTO
          lastName:
              type: string
              length: 255
  
          firstName:
              type: string
              length: 255
  
          streetNumber:
              type: string
              length: 255
  
          street:
              type: string
              length: 255
  
          province:
              type: string
              length: 255
  
          country:
              type: string
              length: 255
  
          homePhone:
              type: string
              length: 255
  
          mobilePhone:
              type: string
              length: 255
          isPlayer:
              type: boolean
              default: false
          isCoach:
              type: boolean
              default: false
  
          dateOfBirth:
              type: date
              column: dateOfBirth
  
      oneToMany:
          children:
              targetEntity: Child
              mappedBy: parent
  
      lifecycleCallbacks: {  }
  </code></pre>
  
  <p><em>/</em></p>
  
  <pre><code>&lt;?php
  
  namespace OSC\UserBundle\Entity;
  
  use FOS\UserBundle\Entity\User as BaseUser;
  use Doctrine\ORM\Mapping as ORM;
  use Symfony\Component\Validator\Constraints as Assert;
  
  
  class User extends BaseUser
  {
  
      protected $id;
  
      public function __construct()
      {
          parent::__construct();
          // your own logic
  
      }
  
     /**
       *
       * @Assert\NotBlank(message="Please enter your last name.", groups={"Registration", "Profile"})
       * @Assert\MinLength(limit="3", message="The name is too short.", groups={"Registration", "Profile"})
       * @Assert\MaxLength(limit="255", message="The name is too long.", groups={"Registration", "Profile"})
       */
       protected $lastName;
  
     /**    
       * @Assert\NotBlank(message="Please enter your first name.", groups={"Registration", "Profile"})
       * @Assert\MinLength(limit="3", message="The name is too short.", groups={"Registration", "Profile"})
       * @Assert\MaxLength(limit="255", message="The name is too long.", groups={"Registration", "Profile"})
       */
       protected $firstName;
  
  
       protected $streetNumber;
  
       protected $street;
  
       protected $province;
  
       protected $country;
  
       protected $postalCode;
  
       protected $homePhone;
  
       protected $mobilePhone;
  
       protected $dateOfBirth;
  
       protected $children;
  
       protected $isPlayer;
  
       protected $isCoach;
  
  
  
      /**
       * Get id
       *
       * @return integer 
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set lastName
       *
       * @param string $lastName
       * @return User
       */
      public function setLastName($lastName)
      {
          $this-&gt;lastName = $lastName;
  
          return $this;
      }
  
      /**
       * Get lastName
       *
       * @return string 
       */
      public function getLastName()
      {
          return $this-&gt;lastName;
      }
  
      /**
       * Set firstName
       *
       * @param string $firstName
       * @return User
       */
      public function setFirstName($firstName)
      {
          $this-&gt;firstName = $firstName;
  
          return $this;
      }
  
      /**
       * Get firstName
       *
       * @return string 
       */
      public function getFirstName()
      {
          return $this-&gt;firstName;
      }
  
      /**
       * Set streetNumber
       *
       * @param string $streetNumber
       * @return User
       */
      public function setStreetNumber($streetNumber)
      {
          $this-&gt;streetNumber = $streetNumber;
  
          return $this;
      }
  
      /**
       * Get streetNumber
       *
       * @return string 
       */
      public function getStreetNumber()
      {
          return $this-&gt;streetNumber;
      }
  
      /**
       * Set street
       *
       * @param string $street
       * @return User
       */
      public function setStreet($street)
      {
          $this-&gt;street = $street;
  
          return $this;
      }
  
      /**
       * Get street
       *
       * @return string 
       */
      public function getStreet()
      {
          return $this-&gt;street;
      }
  
      /**
       * Set province
       *
       * @param string $province
       * @return User
       */
      public function setProvince($province)
      {
          $this-&gt;province = $province;
  
          return $this;
      }
  
      /**
       * Get province
       *
       * @return string 
       */
      public function getProvince()
      {
          return $this-&gt;province;
      }
  
      /**
       * Set country
       *
       * @param string $country
       * @return User
       */
      public function setCountry($country)
      {
          $this-&gt;country = $country;
  
          return $this;
      }
  
      /**
       * Get country
       *
       * @return string 
       */
      public function getCountry()
      {
          return $this-&gt;country;
      }
  
      /**
       * Set homePhone
       *
       * @param string $homePhone
       * @return User
       */
      public function setHomePhone($homePhone)
      {
          $this-&gt;homePhone = $homePhone;
  
          return $this;
      }
  
      /**
       * Get homePhone
       *
       * @return string 
       */
      public function getHomePhone()
      {
          return $this-&gt;homePhone;
      }
  
      /**
       * Set mobilePhone
       *
       * @param string $mobilePhone
       * @return User
       */
      public function setMobilePhone($mobilePhone)
      {
          $this-&gt;mobilePhone = $mobilePhone;
  
          return $this;
      }
  
      /**
       * Get mobilePhone
       *
       * @return string 
       */
      public function getMobilePhone()
      {
          return $this-&gt;mobilePhone;
      }
  
      /**
       * Add children
       *
       * @param \OSC\UserBundle\Entity\Children $children
       * @return User
       */
      public function addChild(\OSC\UserBundle\Entity\Children $children)
      {
          $this-&gt;children[] = $children;
  
          return $this;
      }
  
      /**
       * Remove children
       *
       * @param \OSC\UserBundle\Entity\Children $children
       */
      public function removeChild(\OSC\UserBundle\Entity\Children $children)
      {
          $this-&gt;children-&gt;removeElement($children);
      }
  
      /**
       * Get children
       *
       * @return \Doctrine\Common\Collections\Collection 
       */
      public function getChildren()
      {
          return $this-&gt;children;
      }
  
      /**
       * Set isPlayer
       *
       * @param boolean $isPlayer
       * @return User
       */
      public function setIsPlayer($isPlayer)
      {
          $this-&gt;isPlayer = $isPlayer;
  
          return $this;
      }
  
      /**
       * Get isPlayer
       *
       * @return boolean 
       */
      public function getIsPlayer()
      {
          return $this-&gt;isPlayer;
      }
  
      /**
       * Set isCoach
       *
       * @param boolean $isCoach
       * @return User
       */
      public function setIsCoach($isCoach)
      {
          $this-&gt;isCoach = $isCoach;
  
          return $this;
      }
  
      /**
       * Get isCoach
       *
       * @return boolean 
       */
      public function getIsCoach()
      {
          return $this-&gt;isCoach;
      }
  
      /**
       * Set dateOfBirth
       *
       * @param \DateTime $dateOfBirth
       * @return User
       */
      public function setDateOfBirth($dateOfBirth)
      {
          $this-&gt;dateOfBirth = $dateOfBirth;
  
          return $this;
      }
  
      /**
       * Get dateOfBirth
       *
       * @return \DateTime 
       */
      public function getDateOfBirth()
      {
          return $this-&gt;dateOfBirth;
      }
  }
  </code></pre>
  
  <p>My question is the following</p>
  
  <p>When I run the command: doctrine:schema:validate</p>
  
  <p>why am I getting the following error: </p>
  
  <p><strong>[Mapping]  FAIL - The entity-class 'OSC\UserBundle\Entity\User' mapping is invalid:
  * The association OSC\UserBundle\Entity\User#children refers to the owning side field OSC\UserBundle\Entity\Child#parent which does not exist.</strong></p>
  
  <p>I'm feeling this is linked to parent not being defined in Child. However, when I run doctrine:generate:entities OSC parent is not added....</p>