title: Getting the values of one-to-many relationships in the parent entity?
body: <p>So I have a Doctrine 2 ORM entity, Trust, with several one-to-many relationships. I can't work out how to populate the arrays for these.</p>
  
  <pre><code>class Trust implements \JsonSerializable {
  
      /**
       * @ORM\Id
       * @ORM\Column(type="integer")
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", nullable=true)
       */
      private $name;
  
      /**
       * @ORM\OneToMany(targetEntity="TrustPurpose", mappedBy="trust")
       */
      private $purpose;
  
      public function __construct() {
  
      }
  
      public function jsonSerialize() {
          return [
              'id' =&gt; $this-&gt;id,
              'name' =&gt; $this-&gt;name,
              [...]
              'purpose' =&gt; $this-&gt;purpose,
              [...]
          ];
      }
  
  }
  </code></pre>
  
  <p>In my controller, I might use something like the following.</p>
  
  <pre><code>return new JsonResponse($this-&gt;entityManager-&gt;find(Trust::class, 1));
  </code></pre>
  
  <p>And get the following output</p>
  
  <pre><code>{
      "id" : 1,
      "name" : "Some Trust",
      "purpose" : {
  
      }
  }
  </code></pre>
  
  <p>I'm struggling to find documentation on how to edit entity Trust to automatically populate my purpose records?</p>
  
  <p>TrustPurpose</p>
  
  <pre><code>class TrustPurpose implements \JsonSerializable {
  
      /**
       * @ORM\Id
       * @ORM\Column(type="integer")
       * @ORM\GeneratedValue(strategy="AUTO")
       */
      private $id;
  
      /**
       * @ORM\Column(type="string", nullable=false)
       */
      private $purpose;
  
      /**
       * @ORM\ManyToOne(targetEntity="Trust", inversedBy="purpose")
       * @ORM\JoinColumn(name="trust_id", referencedColumnName="id")
       */
      private $trust;
  
      public function __construct() {
  
      }
  
      public function jsonSerialize() {
          return [
              'id' =&gt; $this-&gt;id,
              'purpose' =&gt; $this-&gt;purpose,
              'trust' =&gt; $this-&gt;trust,
          ];
      }
  
  }
  </code></pre>