I am working with neo4j, I need to make a query to recover a node by the id and can not find the node that I specify, if I filter for another property it does find it but if I specify the id it does not find it. If I go directly from the web and write: MATCH (e:Event) WHERE id(e) = 23 RETURN e
, yes it returns the node I want, but when I do it through the Doctrine repository it does not work. This is my code:
$entityManager = EntityManager::create('bolt://neo4j:1234567@neo4j:7687');
$repository = $entityManager->getRepository(Event::class);
/**@var Event $event*/
$event = $repository->findOneBy(['id' => 23]);
if ($event === null) {
echo 'event not found' . PHP_EOL;
exit(1);
}
echo sprintf("linkId:- %s; externalId: %s; id:%d\n", $event->getLinkId(), $event->getExternalId(), $event->getId());
this is the Event entity:
/**
*
* @OGM\Node(label="Event")
*/
class Event implements ToArrayInterface
{
/**
* @var int
*
* @OGM\GraphId()
*/
protected $id;
/**
* @var string
*
* @OGM\Property(type="string")
*/
protected $linkId;
/**
* @var string
*
* @OGM\Property(type="string")
*/
protected $externalId;
/**
* @var string
*
* @OGM\Property(type="string")
*/
protected $data;
If instead of filtering the property ' id ' filter by the property 'name' , the node returns, that's why I know that node has the id = 23, however, when you filter by the id, it does not find the node, it returns null and therefore 'event not found' .