I like to check if there is data in the repository:
$dataCollection = $this->em->getRepository(Data::class)->DataConnector($fieldId,$id);
if(isset($dataCollection)){
echo "this contains data";
} else {
echo "this does not contain data";
}
But even if no data is in the repository, I always get the message "this contains data".