[英]How to put a variable in a Neo4j cypher query for a repository
I am using spring neo4j. 我正在使用spring neo4j。 I have a
repository
class that extends GraphRepository<T>
. 我有一个扩展
GraphRepository<T>
的repository
类。 I want to delete a specific object based on the uid
in the arguments to the method below. 我想基于以下方法的参数中的
uid
删除特定的对象。
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? 如何使用该方法基于传递给该方法的
uid
删除特定节点?
Or 要么
@Query("START n=node:node_auto_index(uid={uidValueYAA})" +
"MATCH n-[r]-()" +
"DELETE n, r")
public void deleteByUid(@Param("uidValueYAA") String uidValueYAA);
You need to use {0} instead of the name as shown below 您需要使用{0}代替如下所示的名称
@Query("START n=node:node_auto_index(uid={0})" +
"MATCH n-[r]-()" +
"DELETE n, r")
public void deleteByUid(String uidValueYAA);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.