graphaware / neo4j-uuid

GraphAware Runtime Module that assigns a UUID to all nodes (and relationships) in the graph transparently
103 stars 22 forks source link

UUID is not available via cypher immediately upon creation #3

Closed voidstardb closed 9 years ago

voidstardb commented 9 years ago

With graphaware framework and neo4j-uuid plugins installed:

  1. Open the neo4j browser (http://localhost:7474/browser)
  2. Enter the following cypher: create (n {name: "foo"}) return n, n.uuid;
  3. Enter the following cypher: match (n {name: "foo"}) return n, n.uuid;

Actual result: {name: "foo"}, null (from create) {name: "foo", uuid: "<UUID>"}, <UUID> (from match)

Expected result: {name: "foo", uuid: "<UUID>"}, <UUID> {name: "foo", uuid: "<UUID>"}, <UUID>

This issue is reproducible via neo's REST API as well. Not returning the UUID at time of create requires additional cypher queries to get the UUID.

bachmanm commented 9 years ago

Unfortunately, this is how Neo4j works today - if you create a node a return it immediately, its contents do not reflect changes performed by transaction event handlers (i.e., it does not re-read the node before returning it). This is true for all the APIs, the browser, etc. A separate call must be made to get the UUID and I don't think there's any way we can change this behaviour in the framework.

voidstardb commented 9 years ago

Thanks for the explanation.

voidstardb commented 9 years ago

Just for future reference: http://neo4j.com/docs/2.2.1/javadocs/org/neo4j/graphdb/event/TransactionEventHandler.html

beforeCommit The transaction is still open when this method is invoked, making it possible to perform mutating operations in this method. This is however highly discouraged. Changes made in this method are not guaranteed to be visible by this or other TransactionEventHandlers.

There's no other obvious lifecycle hook in which to place the UUID functionality. So, I guess we're stuck with this for now.

Bretto commented 9 years ago

What a shame...

Crodaycat commented 5 years ago

Is there something new about this?

venkat125 commented 4 years ago

But, it is NICE TO HAVE feature though. Can i get the below doubt cleared please?