解雇Cypher查询以了解关系

时间:2016-07-13 12:12:24

标签: neo4j spring-data-neo4j-4 neo4j-ogm

public int getNoOfRelations(long entityId,String relationShipName){     int noOfRelations = 0;     Map< String,Object> map = new SeqncMap< String,Object>();     map.put(" objectId",entityId);     字符串查询=" MATCH(object1) - [r:" + relationShipName             +"] - >(object2){objectId}中的WHERE id(object2)返回count(r)&#34 ;;     结果result = session.query(query,map);     迭代器< Map< String,Object>> iterator = result.iterator();     if(iterator!= null&& iterator.hasNext()){         Map< String,Object> next = iterator.next();         noOfRelations =(int)next.get(" count");     }     return noOfRelations; } 在" session.query(查询,地图)中提供以下异常;"  org.neo4j.ogm.exception.TransactionException:无法执行请求: 17:38:35,793 ERROR [stderr](seqnc-executor-connector-threads - 1)at org.neo4j.ogm.drivers.http.transaction.HttpTransaction.rollback(HttpTransaction.java:49) 17:38:35,796 ERROR [stderr](seqnc-executor-connector-threads - 1)at org.springframework.data.neo4j.transaction.Neo4jTransactionManager.rollback(Neo4jTransactionManager.java:60) 17:38:35,800错误[stderr](seqnc-executor-connector-threads - 1)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 17:38:35,803在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)的错误[stderr](seqnc-executor-connector-threads - 1) 17:38:35,805错误[stderr](seqnc-executor-connector-threads - 1)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 17:38:35,809 java.lang.reflect.Method.invoke中的错误[stderr](seqnc-executor-connector-threads - 1)(Method.java:606) 17:38:35,813 org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection中的错误[stderr](seqnc-executor-connector-threads - 1)(AopUtils.java:302) 17:38:35,817 org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)中的错误[stderr](seqnc-executor-connector-threads - 1) 17:38:35,821 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)中的错误[stderr](seqnc-executor-connector-threads - 1) 17:38:35,827 ERROR [stderr](seqnc-executor-connector-threads - 1)at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 17:38:35,831 ERROR [stderr](seqnc-executor-connector-threads - 1)at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 17:38:35,840 ERROR [stderr](seqnc-executor-connector-threads - 1)at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 17:38:35,843 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)中的错误[stderr](seqnc-executor-connector-threads - 1) 17:38:35,847 com.sun.proxy中的错误[stderr](seqnc-executor-connector-threads - 1)。$ Proxy55.rollback(未知来源) 17:38:35,848 ERROR [stderr](seqnc-executor-connector-threads - 1)at org.springframework.transaction.interceptor.TransactionAspectSupport.completeTransactionAfterThrowing(TransactionAspectSupport.java:539) 17:38:35,854 ERROR [stderr](seqnc-executor-connector-threads - 1)at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:285) 17:38:35,864 ERROR [stderr](seqnc-executor-connector-threads - 1)at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) 17:38:35,868 ERROR [stderr](seqnc-executor-connector-threads - 1)org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 17:38:35,875 ERROR [stderr](seqnc-executor-connector-threads - 1)atg.springframework.aop.framework.CglibAopProxy $ DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) 17:38:35,880 ERROR [stderr](seqnc-executor-connector-threads - 1)at com.seqnc.ui.service.impl.CompanyServiceImpl $$ EnhancerBySpringCGLIB $$ e90d4dcf.deleteLocation(< generated>) 17:38:35,884 ERROR [stderr](seqnc-executor-connector-threads - 1)在com.seqnc.ui.executors.company.department.DeleteLocationExecutor.execute(DeleteLocationExecutor.java: 38)

1 个答案:

答案 0 :(得分:0)

您的查询在IN子句中有WHERE谓词:

WHERE id(object2) in {objectId}

暗示objectId应该是一个集合。

但是,它设置为单longmap.put("objectId", entityId),之前声明为long entityId