neo4j - Spring data wth ne04j error...error while retrieving paths -


i using spring data neo4j.

i used @query annotation place query in repository, query follows

@query(value = "start me=node({0}), friend=node({1}) "             + "match p=shortestpath(me-[:activefriend*..]->friend)"             + " return p")  public iterable<entitypath<user, user>> getshortestpathbetween(user a, user b); 

in controller accessing as

 iterable<entitypath<user, user>> shortestpathbetween = this.queryservice.getshortestpathbetween(user, friend);         (entitypath<user, user> path : shortestpathbetween) {             iterator<user> iter = path.<user>nodeentities().iterator();         } 

when tries access path.nodeentities, causing error:

nested exception java.lang.nullpointerexception] root cause
java.lang.nullpointerexception
@ org.springframework.data.neo4j.support.path.convertingentitypath.nodes(convertingentitypath.java:137)
@ org.springframework.data.neo4j.support.path.convertingentitypath.nodeentities(convertingentitypath.java:69)
@ com.laindain.cms.controller.querycontroller.getshortestpathbetween(querycontroller.java:194)
@ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) @ java.lang.reflect.method.invoke(method.java:601) @ org.springframework.web.method.support.invocablehandlermethod.invoke(invocablehandlermethod.java:212) @ org.springframework.web.method.support.invocablehandlermethod.invokeforrequest(invocablehandlermethod.java:126) @ org.springframework.web.servlet.mvc.method.annotation.servletinvocablehandlermethod.invokeandhandle(servletinvocablehandlermethod.java:96) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.invokehandlermethod(requestmappinghandleradapter.java:617) @ org.springframework.web.servlet.mvc.method.annotation.requestmappinghandleradapter.handleinternal(requestmappinghandleradapter.java:578) @ org.springframework.web.servlet.mvc.method.abstracthandlermethodadapter.handle(abstracthandlermethodadapter.java:80) @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:900) @ org.springframework.web.servlet.dispatcherservlet.doservice(dispatcherservlet.java:827) @ org.springframework.web.servlet.frameworkservlet.processrequest(frameworkservlet.java:882) @ org.springframework.web.servlet.frameworkservlet.dopost(frameworkservlet.java:789) @ javax.servlet.http.httpservlet.service(httpservlet.java:647) @ javax.servlet.http.httpservlet.service(httpservlet.java:728) @ org.apache.catalina.core.applicationfilterchain.internaldofilter(applicationfilterchain.java:305) @ org.apache.catalina.core.applicationfilterchain.dofilter(applicationfilterchain.java:210) @ org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:222) @ org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:123) @ org.apache.catalina.authenticator.authenticatorbase.invoke(authenticatorbase.java:472) @ org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:171) @ org.apache.catalina.valves.errorreportvalve.invoke(errorreportvalve.java:99) @ org.apache.catalina.valves.accesslogvalve.invoke(accesslogvalve.java:936) @ org.apache.catalina.core.standardenginevalve.invoke(standardenginevalve.java:118) @ org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:407) @ org.apache.coyote.http11.abstracthttp11processor.process(abstracthttp11processor.java:1004) @ org.apache.coyote.abstractprotocol$abstractconnectionhandler.process(abstractprotocol.java:589) @ org.apache.tomcat.util.net.aprendpoint$socketprocessor.run(aprendpoint.java:1822) @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1110) @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:603) @ java.lang.thread.run(thread.java:722)

i appreciate if can me on this.

thanks hemant

try defining method way:

public endresult<entitypath<user, user>> getshortestpathbetween(user a, user b); 

since query returns path , not collection of paths. can result follows:

entitypath<user, user> shortestpathbetween = this.queryservice.getshortestpathbetween(user, friend).to(entitypath); 

the nodes , relationships on path can accessed using nodeentities() , relationshipentities() methods on returned entitypath.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -