title: How to not multiply request in symfony when using association table
body: <p>I have a trouble with symfony.
  I have three table in my database :
  Musicien, Composer and Oeuvre
  Composer is an association table between Musicien and Oeuvre.</p>
  
  <p>When I load a page who show a Musicien, it show his Oeuvres.
  So I make a join between Musicien and Composer, and between Composer and Oeuvre.
  From a Musicien I can get all his composer with one request. But, to show his Oeuvres, I need to loop on his Composers to get all Oeuvres.
  It makes one request by get, so if I have n Composer it will makes n request.
  It is horribly slow.</p>
  
  <p>I want to make it with one request, but I don't know how to do that, can you help me ?
  Maybe if I make the join between Musicien and Oeuvre directly, but I don't know how to do that too.</p>
  
  <p>Thank you.</p>
  
  <p>This is my code :</p>
  
  <p>Musicien:
      
  
  <pre><code>namespace App\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  
  /**
   * Musicien
   *
   * @ORM\Table(name="Musicien", indexes={@ORM\Index(name="IDX_AC6BE67520B77BF2", columns={"Code_Pays"}), @ORM\Index(name="IDX_AC6BE675E1990660", columns={"Code_Genre"}), @ORM\Index(name="IDX_AC6BE675D389A975", columns={"Code_Instrument"})})
   * @ORM\Entity
   */
  class Musicien
  {
      /* Some attributes here*/
      /**
       * @var \Composer
       * 
       * @ORM\OneToMany(targetEntity="Composer", mappedBy="codeMusicien")
       */
      private $composer;
  
  
      public function __construct(){
          $this-&gt;oeuvres = new ArrayCollection();
      }
  
  
  
      public function getOeuvres()
      {
          $oeuvres = new ArrayCollection();
          $oeuvres-&gt;add($this-&gt;composer-&gt;getCodeOeuvre());
          // foreach($this-&gt;composer as $c){
          //     $oeuvres-&gt;add($c-&gt;getCodeOeuvre());
          // }
          return $oeuvres;
      }
  
  }
  </code></pre>
  
  <p>Composer</p>
  
  <pre><code>&lt;?php
  
  namespace App\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * Composer
   *
   * @ORM\Table(name="Composer", indexes={@ORM\Index(name="IDX_6105648EE694D5AB", columns={"Code_Musicien"}), @ORM\Index(name="IDX_6105648ECB48FCBD", columns={"Code_Oeuvre"})})
   * @ORM\Entity
   */
  class Composer
  {
      /**
       * @var int
       *
       * @ORM\Column(name="Code_Composer", type="integer", nullable=false)
       * @ORM\Id
       * @ORM\GeneratedValue(strategy="IDENTITY")
       */
      private $codeComposer;
  
      /**
       * @var \Musicien
       *
       * @ORM\ManyToOne(targetEntity="Musicien", inversedBy="composer")
       * @ORM\JoinColumns({
       *   @ORM\JoinColumn(name="Code_Musicien", referencedColumnName="Code_Musicien")
       * })
       */
      private $codeMusicien;
  
      /**
       * @var \Oeuvre
       *
       * @ORM\ManyToOne(targetEntity="Oeuvre", inversedBy="composer")
       * @ORM\JoinColumns({
       *   @ORM\JoinColumn(name="Code_Oeuvre", referencedColumnName="Code_Oeuvre")
       * })
       */
      private $codeOeuvre;
  
      public function getCodeComposer(): ?int
      {
          return $this-&gt;codeComposer;
      }
  
      public function getCodeMusicien(): ?Musicien
      {
          return $this-&gt;codeMusicien;
      }
  
      public function setCodeMusicien(?Musicien $codeMusicien): self
      {
          $this-&gt;codeMusicien = $codeMusicien;
  
          return $this;
      }
  
      public function getCodeOeuvre(): ?Oeuvre
      {
          return $this-&gt;codeOeuvre;
      }
  
      public function setCodeOeuvre(?Oeuvre $codeOeuvre): self
      {
          $this-&gt;codeOeuvre = $codeOeuvre;
  
          return $this;
      }
  
  
  }
  </code></pre>
  
  <p>Oeuvre</p>
  
  <pre><code>&lt;?php
  
  namespace App\Entity;
  
  use Doctrine\ORM\Mapping as ORM;
  use Doctrine\Common\Collections\ArrayCollection;
  
  /**
   * Oeuvre
   *
   * @ORM\Table(name="Oeuvre", indexes={@ORM\Index(name="IDX_32522BC898F61075", columns={"Code_Type"})})
   * @ORM\Entity
   */
  class Oeuvre
  {
      /**
       * Some attributes here
       */
  
      /**
       * @var \Composer
       * 
       * @ORM\OneToMany(targetEntity="Composer", mappedBy="codeOeuvre")
       * @ORM\JoinTable(name="Composer")
       */
      private $composer;
  
  
      public function __construct(){
          $this-&gt;musiciens = new ArrayCollection();
      }
  
      public function getMusiciens()
      {
          $musiciens = new ArrayCollection();
          foreach($this-&gt;composer as $c){
              $musiciens-&gt;add($c-&gt;getCodeMusicien());
          }
          return $musiciens;
      }
  
  }
  </code></pre>