Spring Data Neo4j Neo.ClientError.Statement.EntityNotFound;描述:无法加载带ID的NODE

时间:2016-07-10 19:37:17

标签: neo4j cypher

我有以下Neo4j架构:

enter image description here

我尝试使用Cypher查询删除带有以下SDN 4.2.0.BUILD-SNAPSHOT存储库的节点:

@Query("MATCH (d:Decision) WHERE id(d) IN {decisionsIds} OPTIONAL MATCH (d)<-[:COMMENTED_ON*]-(com:Comment) DETACH DELETE com WITH d OPTIONAL MATCH (d)<-[:DEFINED_BY]-(c) WITH d, c OPTIONAL MATCH (c)<-[:VOTED_ON]-(vg) WITH d, c, vg OPTIONAL MATCH (vg)-[:CONTAINS]->(v) DETACH DELETE v, vg, c, d")
void deleteDecisions(@Param("decisionsIds") List<Long> decisionsIds);

现在我在执行此方法后遇到以下异常:

org.neo4j.ogm.exception.CypherException: Error executing Cypher; Code: Neo.ClientError.Statement.EntityNotFound; Description: Unable to load NODE with id 2157.
    at org.neo4j.ogm.drivers.embedded.request.EmbeddedRequest.executeRequest(EmbeddedRequest.java:176)
    at org.neo4j.ogm.drivers.embedded.request.EmbeddedRequest.execute(EmbeddedRequest.java:144)
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:93)
    at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:73)
    at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:313)
    at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:61)
    at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:52)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
    at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy125.deleteDecisions(Unknown Source)  

其中ID为2157的NODE为VoteGroup实体。

这是我的实体:

@NodeEntity
public class VoteGroup extends BaseEntity {

    private static final String VOTED_ON = "VOTED_ON";
    private final static String VOTED_FOR = "VOTED_FOR";
    private final static String CONTAINS = "CONTAINS";

    @Relationship(type = VOTED_FOR, direction = Relationship.OUTGOING)
    private Decision decision;

    @Relationship(type = VOTED_ON, direction = Relationship.OUTGOING)
    private Criterion criterion;

    @Relationship(type = CONTAINS, direction = Relationship.OUTGOING)
    private Set<Vote> votes = new HashSet<>();

    private double avgVotesWeight;

    private long totalVotesCount;

    public VoteGroup() {
    }

    public VoteGroup(Decision decision, Criterion criterion, double avgVotesWeight, long totalVotesCount) {
        this.decision = decision;
        decision.addVoteGroup(this);
        this.criterion = criterion;
        criterion.addVoteGroup(this);
        this.avgVotesWeight = avgVotesWeight;
        this.totalVotesCount = totalVotesCount;
    }
...
}

@NodeEntity
public class Vote extends Authorable {

    private final static String CONTAINS = "CONTAINS";

    @Relationship(type = CONTAINS, direction = Relationship.INCOMING)
    private VoteGroup group;

    private double weight;

    private String description;

    public Vote() {
    }

    public Vote(VoteGroup group, User author, double weight, String description) {
        this.group = group;
        group.addVote(this);
        setAuthor(author);
        this.weight = weight;
        this.description = description;
    }
...
}

我的查询有什么问题?

已更新

我也在Standalone Neo4j服务器上尝试了这个,结果相同:

enter image description here

enter image description here

2 个答案:

答案 0 :(得分:1)

这看起来像是一个Neo4j问题,请在https://github.com/neo4j/neo4j/issues上使用您的查询,EXPLAIN计划和错误消息进行登录。

与此同时,如果您删除早期删除评论并在结尾处完成所有操作,您应该能够继续前进:

MATCH (d:Decision) WHERE id(d) IN [155, 163, 144]  
OPTIONAL MATCH (d)<-[:COMMENTED_ON*]-(com:Comment) 
OPTIONAL MATCH (d)<-[:DEFINED_BY]-(c) 
OPTIONAL MATCH (c)<-[:VOTED_ON]-(vg) 
OPTIONAL MATCH (vg)-[:CONTAINS]->(v) 
DETACH DELETE v, vg, c, d,com

答案 1 :(得分:0)

我有完全相同的问题是由于 &#34;的Neo4j-OGM嵌入驱动器&#34;我用在我的pom中的版本。 我意外地覆盖了版本&#34; spring-data-neo4j&#34; 默认情况下使用(2.0.3)和2.0.5。这导致了 描述的问题..