title: One-to-many CRITICAL - Uncaught PHP Exception Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException
body: <p>Trying to set up two simple objects <code>Purchase</code> and <code>Address</code>.</p>
  
  <p>One Purchase can have multiple Addresses (purchase address, invoice address)</p>
  
  <p>Simplified ORM from Address Entity looks like:</p>
  
  <pre><code>X\Entity\Address:
      repositoryClass: X\Repository\AddressRepository
      type: entity
      manyToOne:
          purchase:
              targetEntity: Purchase
              inversedBy: addresses
              joinColumn:
                  name: purchase_id
                  referencedColumnName: id
      id:
          id:
              type: integer
              id: true
              generator:
                  strategy: AUTO
      fields:
          firstname:
              type: string
              length: 255
          email:
              type: string
              length: 255
      lifecycleCallbacks: {  }
  </code></pre>
  
  <p>Simplified ORM from Purchase Entity looks like:</p>
  
  <pre><code>X\Entity\Purchase:
      repositoryClass: X\Repository\PurchaseRepository
      type: entity
      oneToMany:
          addresses:
              targetEntity: Address
              mappedBy: purchase
      id:
          id:
              type: integer
              id: true
              generator:
                  strategy: AUTO
      fields:
          quantity:
              type: integer
          orderedAt:
              type: datetime
          toBeDeliveredAt:
              type: datetime
      lifecycleCallbacks: {  }
  </code></pre>
  
  <p>Now these lines from the Purchase Class give me error</p>
  
  <pre><code>/**
   * @return \Doctrine\Common\Collections\Collection
   */
  public function getAddresses()
  {
      return $this-&gt;addresses;
  }
  </code></pre>
  
  <p><strong>saying:</strong></p>
  
  <blockquote>
    <p>Neither the property "address" nor one of the methods "getAddress()",
    "address()", "isAddress()", "hasAddress()", "__get()" exist and have
    public access in class "X\Entity\Purchase".</p>
  </blockquote>
  
  <p>Which is absolutely correct, there is no Property <code>address</code> and there aren't any methods for that non existing property.</p>
  
  <p>Problem is kind of the Property name is <code>addresses</code> and there is a method <code>getAddresses</code> but something goes wrong with that. </p>
  
  <p>Now the question is why is "the system" (symfony?) searching for a property name <code>address</code>? And of course how can I solve this?</p>
  
  <p><strong>Update</strong></p>
  
  <p>The error occurs on form submission. The Controller looks like this:</p>
  
  <pre><code>class DefaultController extends Controller
  {
      public function indexAction(Request $request)
      {
          $purchase = new Purchase();
          $form = $this-&gt;createFormBuilder($purchase)
              -&gt;add('address', AddressType::class)
              -&gt;add('quantity', IntegerType::class)
              -&gt;add('toBeDeliveredAt', DateType::class)
              -&gt;add('comment', TextareaType::class)
              -&gt;add('save', SubmitType::class, array('label' =&gt; 'Submit'))
              -&gt;getForm();
  
          $form-&gt;handleRequest($request);
          if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {
              $em = $this-&gt;getDoctrine()-&gt;getManager();
              $em-&gt;persist($purchase);
              $em-&gt;flush();
          }
  
  
          return $this-&gt;render('X:Default:index.html.twig', array(
              'form' =&gt; $form-&gt;createView(),
          ));
      }
  }
  </code></pre>
  
  <p>And the AddressType looks like this: </p>
  
  <pre><code>class AddressType extends AbstractType
  {
  
      public function buildForm(FormBuilderInterface $builder, array $options)
      {
          $builder
              -&gt;add('firstname', TextType::class)
              -&gt;add('email', EmailType::class);
      }
  }
  </code></pre>
  
  <p>Thanks for helping!</p>
  
  <p>If needed the entire Purchase Class looks like this:</p>
  
  <pre><code>&lt;?php
  
  namespace X\Entity;
  
  use Doctrine\Common\Collections\ArrayCollection;
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * Purchase
   */
  class Purchase
  {
      /**
       * @var int
       */
      private $id;
  
      /**
       * @var int
       */
      private $quantity;
  
      /**
       * @var \DateTime
       */
      private $orderedAt;
  
      /**
       * @var \DateTime
       */
      private $toBeDeliveredAt;
  
      /**
       * @var bool
       */
      private $delivered;
  
      /**
       * @var \DateTime
       */
      private $deliveredAt;
  
      /**
       * @var bool
       */
      private $payd;
  
      /**
       * @var \DateTime
       */
      private $paydAt;
  
      /**
       * @var string
       */
      private $comment;
  
      /**
       * @var \Doctrine\Common\Collections\Collection
       */
      private $addresses;
  
      /**
       *
       */
      public function __construct()
      {
          $this-&gt;addresses = new ArrayCollection();
      }
  
  
      /**
       * Get id
       *
       * @return integer
       */
      public function getId()
      {
          return $this-&gt;id;
      }
  
      /**
       * Set quantity
       *
       * @param integer $quantity
       * @return Purchase
       */
      public function setQuantity($quantity)
      {
          $this-&gt;quantity = $quantity;
  
          return $this;
      }
  
      /**
       * Get quantity
       *
       * @return integer
       */
      public function getQuantity()
      {
          return $this-&gt;quantity;
      }
  
      /**
       * Set orderedAt
       *
       * @param \DateTime $orderedAt
       * @return Purchase
       */
      public function setOrderedAt($orderedAt)
      {
          $this-&gt;orderedAt = $orderedAt;
  
          return $this;
      }
  
      /**
       * Get orderedAt
       *
       * @return \DateTime
       */
      public function getOrderedAt()
      {
          return $this-&gt;orderedAt;
      }
  
      /**
       * @param \DateTime $toBeDeliveredAt
       */
      public function setToBeDeliveredAt($toBeDeliveredAt)
      {
          $this-&gt;toBeDeliveredAt = $toBeDeliveredAt;
      }
  
      /**
       * @return \DateTime
       */
      public function getToBeDeliveredAt()
      {
          return $this-&gt;toBeDeliveredAt;
      }
  
      /**
       * @param Address $address
       * @return Address
       */
      public function addAddress(Address $address)
      {
          $this-&gt;addresses[] = $address;
          if($address-&gt;getPurchase() !== $this) {
              $address-&gt;setPurchase($this);
          }
          return $this;
      }
  
      /**
       * @return \Doctrine\Common\Collections\Collection
       */
      public function getAddresses()
      {
          return $this-&gt;addresses;
      }
  }
  </code></pre>