I am using symfony 5.4 with doctrine-bundle 2.4. I've got an entity "sending" where I connect addresses with different connections
class Sending
{
...
/**
* @ORM\ManyToMany(targetEntity=Address::class, inversedBy="getSendingAsSender")
* @ORM\JoinTable(name="sending_sender_address")
*/
private $sender;
/**
* @ORM\ManyToMany(targetEntity=Address::class, inversedBy="getSendingAsRecipient")
* @ORM\JoinTable(name="sending_recipient_address")
*/
private $recipient;
}
and the corresponding address entity.
When creating an object of type sending I can access sender and recipient, so the definitions of the objects seem to be fine.
Now I want to create a list of all senders OR recipients by using querybuilder
$builder = $this->entitiyManager->getRepository(Sending::class)
->createQueryBuilder('s')
->join(Address::class, 'a')
...
This creates a
select ... from sending s inner join address a
without any connection data or on clauses and without the m:n join table in between. When adding a ->join('sending_sender_address','sa') before the address join it tells me, that there is not entity sending_sender_address.
What I finally need is a collection of address objects which are senders (or recipients) of any or selected sendings.
How do I do that connection properly and how can I choose which of the connection tables should be used?