return the value uuid in the nodes created in Neo4j ogm

232 Views Asked by At

I'm working Neo4j from PHP. To generate the uuid field in the nodes I am using: neo4j-uuid. I also use: graphaware/neo4j-php-ogm, when I create a node, I do not return the value assigned to the UUID field, I have to make a new query to get that value, I need to hydrate the UUID value automatically when the object is created, just like the ID is hydrated.

2

There are 2 best solutions below

3
On BEST ANSWER

From the GraphAware Neo4j UUID Github Repo:

If you create a node and return it immediately, its contents will not reflect changes performed by transaction event handlers such as this one -- thus the UUID will not be available. A separate call must be made to get the UUID.

That is: this is the expected behavior. Currently you should make a new query to get the node with the generated UUID property.

0
On

As it says @bruno-peres the value of the uuid is not automatically hydrated, so I invoke the refresh method of the EntityManager

$this->em->persist($entity);
$this->em->flush();
$this->em->refresh($entity);
var_dump($p->getUuid())