public function __construct(Connection $connection, DbalMapper $mapperOne, DbalMapper $mapperTwo, PropertyMetadata $metadata)
 {
     $this->connection = $connection;
     $this->mapperOne = $mapperOne;
     $this->mapperTwo = $mapperTwo;
     $this->metadata = $metadata;
     $parameters = $mapperOne->getManyHasManyParameters($metadata, $mapperTwo);
     $this->joinTable = $parameters[0];
     if ($this->metadata->relationship->isMain) {
         $this->targetRepository = $this->mapperTwo->getRepository();
         list($this->primaryKeyFrom, $this->primaryKeyTo) = $parameters[1];
     } else {
         $this->targetRepository = $this->mapperOne->getRepository();
         list($this->primaryKeyTo, $this->primaryKeyFrom) = $parameters[1];
     }
 }
 public function __construct(Connection $connection, DbalMapper $targetMapper, PropertyMetadata $metadata)
 {
     $this->connection = $connection;
     $this->targetMapper = $targetMapper;
     $this->targetRepository = $targetMapper->getRepository();
     $this->metadata = $metadata;
     $this->joinStorageKey = $targetMapper->getStorageReflection()->convertEntityToStorageKey($this->metadata->relationship->property);
 }