em->createQuery( 'SELECT t.id FROM ' . TenantInsurance::class . ' t WHERE t.entityType = :type AND t.entityId = :id' )->setParameter('type', $entityType) ->setParameter('id', $entityId) ->getSingleColumnResult(); if ($tenantInsuranceIds !== []) { $this->em->createQuery( 'DELETE ' . TenantServiceCoverage::class . ' c WHERE c.tenantInsuranceId IN (:ids)' )->setParameter('ids', $tenantInsuranceIds)->execute(); } $this->em->createQuery( 'DELETE ' . TenantInsurance::class . ' t WHERE t.entityType = :type AND t.entityId = :id' )->setParameter('type', $entityType) ->setParameter('id', $entityId) ->execute(); $this->em->createQuery( 'DELETE ' . EntityInsurancePricing::class . ' p WHERE p.entityType = :type AND p.entityId = :id' )->setParameter('type', $entityType) ->setParameter('id', $entityId) ->execute(); } }