Database: NEO4J CE 3.5.11 (also reproduced on NEO4J EE 3.5.11)
Driver: 4.0.0-beta02
Java Version: openjdk 11
I am trying to apply "MERGE / ON CREATE SET / ON MATCH SET" logic to Nodes decorated with a uniqueness constraint on one property. Using the browser client, I'm able to merge & match the node, but using the java driver I get this
org.neo4j.driver.exceptions.ClientException: Node(78251) already exists with label
MyNode and property
keyprop = '1001632'
What does the Browser Client do the Java Driver doesn't?
1) Background / "nano data model"
The "MyNode" stoods for a Node value, whose properties spring from a "daily" dataset. The dataset may differ from the previous days dataset in that it contains properties for additional "MyNode", does not contain properties of a certain "MyNode" any longer, does contain changed properties for a "MyNode". Each MyNode instance is uniquely identified by a property.
2) Demo
Please find some sample code for playing around with the issue below.
3) Code Precondition (Constraint, Anchor-Node)
CREATE CONSTRAINT ON (n:MyNode) ASSERT n.keyprop IS UNIQUE
MERGE (an:Anchor {key: "Anchor-01"})
4) Code called once and subsequently
MATCH (an:Anchor {key: "Anchor-01"})
MERGE (an)<-[:ANCHORS]-(m:MyNode {keyprop: "key1234"})
ON CREATE SET
m.name = "m1234" ,
m.etc = "etc. pp." ,
m.created = timestamp()
ON MATCH SET
m.name = "m1234" ,
m.etc = "etc. pp." ,
m.seen = timestamp()