src/Mapper/Relation/HasAndBelongsToMany.php
protected function deleteRelation(
        EntityInterface $entity,
        EntityCollectionInterface $collection
    ) {
        $repository = $this->getParentRepository();
        $adapter = $repository->getAdapter();
        $parts = explode('\\', $this->getEntityDescriptor()->className());
        $entityName = lcfirst(array_pop($parts));
        $parts = explode('\\', $this->getParentEntityDescriptor()->className());
        $relatedName = lcfirst(array_pop($parts));
        $value = $collection->parentEntity()->getId();
        Sql::createSql($adapter)
            ->delete($this->getRelationTable())
            ->where(
                [
                    "{$this->getRelatedForeignKey()} = :{$relatedName} AND
                     {$this->getForeignKey()} = :{$entityName}" => [
                        ":{$relatedName}" => $entity->getId(),
                        ":{$entityName}" => $value
                    ]
                ]
            )
            ->execute();
        return $this;
    }
protected function deleteRelation(
        EntityInterface $entity,
        EntityCollectionInterface $collection
    ) {
        $repository = $this->getParentRepository();
        $adapter = $repository->getAdapter();
        $parts = explode('\\', $this->getEntityDescriptor()->className());
        $entityName = lcfirst(array_pop($parts));
        $parts = explode('\\', $this->getParentEntityDescriptor()->className());
        $relatedName = lcfirst(array_pop($parts));
        $value = $collection->parentEntity()->getId();
        Sql::createSql($adapter)
            ->delete($this->getRelationTable())
            ->where(
                [
                    "{$this->getRelatedForeignKey()} = :{$relatedName} AND
                     {$this->getForeignKey()} = :{$entityName}" => [
                        ":{$relatedName}" => $entity->getId(),
                        ":{$entityName}" => $value
                    ]
                ]
            )
            ->execute();
        return $this;
    }
protected function deleteRelation ( EntityInterface $ entity , EntityCollectionInterface $ collection ) { $ repository = $ this -> getParentRepository ( ) ; $ adapter = $ repository -> getAdapter ( ) ; $ parts = explode ( '\\' , $ this -> getEntityDescriptor ( ) -> className ( ) ) ; $ entityName = lcfirst ( array_pop ( $ parts ) ) ; $ parts = explode ( '\\' , $ this -> getParentEntityDescriptor ( ) -> className ( ) ) ; $ relatedName = lcfirst ( array_pop ( $ parts ) ) ; $ value = $ collection -> parentEntity ( ) -> getId ( ) ; Sql :: createSql ( $ adapter ) -> delete ( $ this -> getRelationTable ( ) ) -> where ( [ "{$this->getRelatedForeignKey()} = :{$relatedName} AND
                     {$this->getForeignKey()} = :{$entityName}" => [ ":{$relatedName}" => $ entity -> getId ( ) , ":{$entityName}" => $ value ] ] ) -> execute ( ) ; return $ this ; }
Removes existing relations

@param EntityInterface $entity
@param EntityCollectionInterface $collection

@return self
Removes existing relations