Skip to content

Commit 398d9b6

Browse files
committed
feat: update query on cypher
Signed-off-by: Otavio Santana <[email protected]>
1 parent 05295f2 commit 398d9b6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

jnosql-neo4j/src/main/java/org/eclipse/jnosql/databases/neo4j/communication/DefaultNeo4JDatabaseManager.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ public CommunicationEdge edge(CommunicationEntity source, String label, Communic
330330

331331
String cypher = "MATCH (s) WHERE elementId(s) = $sourceElementId " +
332332
"MATCH (t) WHERE elementId(t) = $targetElementId " +
333-
"CREATE (s)-[r:" + label + " $props]->(t) RETURN r";
333+
"WITH s, t " +
334+
"WHERE NOT EXISTS { MATCH (s)-[r:" + label + "]->(t) } " +
335+
"CREATE (s)-[r:" + label + " $props]->(t) " +
336+
"RETURN r";
334337

335338
try (Transaction tx = session.beginTransaction()) {
336339
var sourceId = source.find(ID).orElseThrow(() ->

0 commit comments

Comments
 (0)