Thursday, 19 September 2013

How to put a variable in a Neo4j cypher query for a repository

How to put a variable in a Neo4j cypher query for a repository

I am using spring neo4j. I have a repository class that extends
GraphRepository<T>. I want to delete a specific object based on the uid in
the arguments to the method below.
public interface TypeRepository extends GraphRepository<Type> {
@Query("START n=node:node_auto_index(uid=uidValueYAA)" +
"MATCH n-[r]-()" +
"DELETE n, r")
public void deleteByUid(String uidValueYAA);
}
Note: my persisted class has an index annotation like the following:
@GraphId
private Long id;
@Indexed(unique=true) private String uid;
I get the following exception when I use the method like so:
typeRepository.deleteByUid(uid);
//The Exception
string literal or parameter expected|"START
n=node:node_auto_index(uid=uidValueYAA)MATCH n-[r]-()DELETE n, r"|
How can I use the method to delete a specific node based on the uid that I
pass to the method?

No comments:

Post a Comment