Closed jarellm closed 8 years ago
Hi,
The reason why it's done in beforeCommit
is that in afterCommit
the transaction has been commited so no changes can be done in the database anymore.
Note that as Cypher would already have compiled the result to the user, it is impossible for the plugin to return the uuid property as part of the result, so I'm afraid it can't be used as like you want without an extra statement sent to the database.
You would better use an application side uuid generator, like eaio uuid
and add the uuid on the node property in the before save event like explained in the article you mentioned.
NB: Technically it is possible to use the plugin if OGM would support it as an ID Generation Strategy, meaning that during the commit, the OGM would now if this plugin is used and perform an extra statement to retrieve the uuid properties of the given node ids, this would involve a LOT of changes but can be a nice idea of extensibility points of the OGM, I'll discuss this with the team for the long term plan of the OGM.
Thanks for the clarification Cristophe. I understand it can't be done in afterCommit, and like you said, requires changes in Neo4J itself to support such behavior. It just makes me wonder why Neo4j has limited itself to beforeCommit and afterCommit transaction listeners.
Currently UUID assignment happens in the before commit phase.
Are there any plans to support Event.TYPE.POST_SAVE as mentioned here
http://graphaware.com/neo4j/2016/04/13/neo4j-ogm-events-part-1.html
such that the plugin behaves like JPA's IdGenerator and Oracle's sequence?