private function buildRequiredOwnerFilter(GetFilterEvent $event, $filter)
    {
        $connection = $event->getConnection();
        $platform = $connection->getDatabasePlatform();
        $targetEntity = $event->getTargetEntity();
        $targetTableAlias = $event->getTargetTableAlias();

        $identifier = DoctrineUtils::castIdentifier($targetEntity, $connection);
        $ownerId = $event->getRealParameter('user_id');
        $ownerColumn = $this->getAssociationColumnName($targetEntity, 'owner');
        $ownerFilter = null !== $ownerId
            ? "{$targetTableAlias}.{$ownerColumn}{$identifier} = {$connection->quote($ownerId)}"
            : "{$platform->getIsNullExpression($targetTableAlias.'.'.$ownerColumn)}";

        return <<<SELECTCLAUSE
{$ownerFilter}
    OR
({$filter})
SELECTCLAUSE;
    }