title: DQL request in SYmfony having two relations and returning an empty array
body: <p>Hello there have something i dont understand about SQL i guess. I linked below the code and the image about my db shema for help you to understand.
  So my problem with this request is that it return an empty array and i dont understand why its not working as from my understanding it should return an array containing all the &quot;r.messages&quot; that have the specified ID related to the fields relation. What do i do wrong ?</p>
  <p>PS: for some context helping your understanding, im trying to build a messagery system from a user to another. The SQL request i try to do should return the conversation between two users.</p>
  <pre><code>public function listOfMessages($value, $value2)
  {
      return $this-&gt;createQueryBuilder('user')
          -&gt;select('r.message')
          -&gt;innerJoin('user.sender', 's')
          -&gt;innerJoin('user.receiver', 'r')
          -&gt;where('s.sender = :value')
          -&gt;andWhere('r.recipient = :value2')
          -&gt;setParameter(':value', $value)
          -&gt;setParameter(':value2', $value2)
          -&gt;getQuery()
          -&gt;getResult()
      ;
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/VXdqA.jpg" rel="nofollow noreferrer">DB shema</a></p>
  <p>Entity User</p>
  <pre><code>    use App\Repository\PrivateMessageRepository;
      use Doctrine\ORM\Mapping as ORM;
  
      /**
      * @ORM\Entity(repositoryClass=PrivateMessageRepository::class)
       */
      class PrivateMessage
      {
  /**
   * @ORM\Id
   * @ORM\GeneratedValue
   * @ORM\Column(type=&quot;integer&quot;)
   */
  private $id;
  
  /**
   * @ORM\Column(type=&quot;text&quot;, nullable=true)
   */
  private $message;
  
  /**
   * @ORM\ManyToOne(targetEntity=User::class, inversedBy=&quot;sender&quot;)
   */
  private $sender;
  
  /**
   * @ORM\ManyToOne(targetEntity=user::class, inversedBy=&quot;receiver&quot;)
   */
  private $recipient;
  
  /**
   * @ORM\Column(type=&quot;boolean&quot;, nullable=true)
   */
  private $isRead = 0;
  
  /**
   * @ORM\Column(type=&quot;datetime_immutable&quot;, nullable=true)
   */
  private $sentAt;
  
  public function getId(): ?int
  {
      return $this-&gt;id;
  }
  
  public function getMessage(): ?string
  {
      return $this-&gt;message;
  }
  
  public function setMessage(?string $message): self
  {
      $this-&gt;message = $message;
  
      return $this;
  }
  
  public function getSender(): ?User
  {
      return $this-&gt;sender;
  }
  
  public function setSender(?User $sender): self
  {
      $this-&gt;sender = $sender;
  
      return $this;
  }
  
  public function getRecipient(): ?user
  {
      return $this-&gt;recipient;
  }
  
  public function setRecipient(?user $recipient): self
  {
      $this-&gt;recipient = $recipient;
  
      return $this;
  }
  
  public function getIsRead(): ?bool
  {
      return $this-&gt;isRead;
  }
  
  public function setIsRead(?bool $isRead): self
  {
      $this-&gt;isRead = $isRead;
  
      return $this;
  }
  
  public function getSentAt(): ?\DateTimeImmutable
  {
      return $this-&gt;sentAt;
  }
  
  public function setSentAt(?\DateTimeImmutable $sentAt): self
  {
      $this-&gt;sentAt = $sentAt;
  
      return $this;
  }
  </code></pre>
  <p>}</p>
  <p>Entity privateMessage</p>
  <pre><code>use App\Repository\PrivateMessageRepository;
  use Doctrine\ORM\Mapping as ORM;
  
  /**
   * @ORM\Entity(repositoryClass=PrivateMessageRepository::class)
   */
  class PrivateMessage
  {
  /**
   * @ORM\Id
   * @ORM\GeneratedValue
   * @ORM\Column(type=&quot;integer&quot;)
   */
  private $id;
  
  /**
   * @ORM\Column(type=&quot;text&quot;, nullable=true)
   */
  private $message;
  
  /**
   * @ORM\ManyToOne(targetEntity=User::class, inversedBy=&quot;sender&quot;)
   */
  private $sender;
  
  /**
   * @ORM\ManyToOne(targetEntity=user::class, inversedBy=&quot;receiver&quot;)
   */
  private $recipient;
  
  /**
   * @ORM\Column(type=&quot;boolean&quot;, nullable=true)
   */
  private $isRead = 0;
  
  /**
   * @ORM\Column(type=&quot;datetime_immutable&quot;, nullable=true)
   */
  private $sentAt;
  
  public function getId(): ?int
  {
      return $this-&gt;id;
  }
  
  public function getMessage(): ?string
  {
      return $this-&gt;message;
  }
  
  public function setMessage(?string $message): self
  {
      $this-&gt;message = $message;
  
      return $this;
  }
  
  public function getSender(): ?User
  {
      return $this-&gt;sender;
  }
  
  public function setSender(?User $sender): self
  {
      $this-&gt;sender = $sender;
  
      return $this;
  }
  
  public function getRecipient(): ?user
  {
      return $this-&gt;recipient;
  }
  
  public function setRecipient(?user $recipient): self
  {
      $this-&gt;recipient = $recipient;
  
      return $this;
  }
  
  public function getIsRead(): ?bool
  {
      return $this-&gt;isRead;
  }
  
  public function setIsRead(?bool $isRead): self
  {
      $this-&gt;isRead = $isRead;
  
      return $this;
  }
  
  public function getSentAt(): ?\DateTimeImmutable
  {
      return $this-&gt;sentAt;
  }
  
  public function setSentAt(?\DateTimeImmutable $sentAt): self
  {
      $this-&gt;sentAt = $sentAt;
  
      return $this;
  }
  }
  </code></pre>