I have an edge with sevral properties. I would like to keep the edge but remove only the name property.
My java Cypher is this :
public static final String DELETE_EDGE_PROPERTY_QUERY = //
"MATCH ()-[r]->() where id(r) = {1} REMOVE r.{2} RETURN r"; //
It works on cypher console but doesn't work on jdbc.
I got this error :
processing failed; nested exception is org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [MATCH ()-[r]->() where id(r) = {1} REMOVE r.{2} RETURN r]; SQL state [null]; error code [0]; Some errors occurred : [Neo.ClientError.Statement.SyntaxError]:Invalid input '{': expected an identifier, whitespace, a function name or a property key name (line 1, column 45 (offset: 44)) "MATCH ()-[r]->() where id(r) = {1} REMOVE r.{2} RETURN r" `
Any suggestions?
Thanks
EDIT
I couldn't do with jdbc template. so I have used String replacement: Setting the property to NULL will delete the property (http://www.baeldung.com/java-neo4j)
Solution : Java :
String deleteQuery = String.format(DELETE_EDGE_PROPERTY_QUERY, property);
plantJdbcTemplate.update(deleteQuery, edgeId);
cypher :
public static final String DELETE_EDGE_PROPERTY_QUERY = //
"MATCH ()-[r]->() where id(r) = {1} SET r.%s = NULL RETURN r";
{:id}
instead of indexes. – RP-MATCH ()-[r]->() where id(r) = {:id} REMOVE r.name RETURN r
– RP-