2

Prior to migrating my project to SDN 4, I used my own custom REST client code which generated Cypher statements of the form:

MERGE (n:LABEL1:LABEL2 {prop1:"val"...})
ON CREATE SET ...
ON MATCH SET ...

This had the desired effect of creating nodes which needed to be created, and updating existing nodes where necessary.

However, using .save(...) on the SDN 4 Neo4jTemplate, only CREATE Cypher statements appear to be generated, resulting in duplicate nodes, where what is desired is new nodes are created if necessary and existing nodes are updated and new relationships are added to existing nodes where possible.

Is there a way to influence the SDN 4 Neo4jTemplate behaviour to use MERGE rather than CREATE?

Luanne
  • 19,145
  • 1
  • 39
  • 51
GavinM
  • 80
  • 6
  • 1
    SDN4 should only be creating new nodes if they're new and update existing nodes if modified. Please post the entity you're saving and what conditions cause duplicate nodes – Luanne Jul 08 '15 at 16:42
  • I may have misunderstood the correct usage of the graph id property. I'll do some further investigations and either come back with a more detailed question, or explain what I'd done wrong so other's don't make the same mistake. – GavinM Jul 09 '15 at 09:44
  • The @GraphId is the node or relationship id used to attach the entity to the graph. It's null before you save an entity and upon save, populated with the id assigned to it – Luanne Jul 09 '15 at 09:52
  • The mistake I made was to try running before I could walk here. I had a complex compound entity I was trying to save, which contained duplicate sub-entities. I've now written the necessary code to iterate over that complex entity and save it, piece by piece, updating the id of duplicated parts as I go, thereby preventing duplicate objects being created. I'll write this up properly and post some example code later. – GavinM Jul 09 '15 at 15:50

0 Answers0