Spring Data Neo4j - Getting an exception when running a cypher query -
i'm getting strange exception when trying run simple cypher query. first i'll introduce code, , i'll show cause exception. have following classes:
a simple class represent user profile:
public abstract class profile extends abstractentity { @indexed profiletype profiletype; @indexed(indextype = indextype.fulltext, indexname = "name") string firstname; @indexed(indextype = indextype.fulltext, indexname = "name") string lastname; @indexed eyecolor eyecolor; @indexed haircolor haircolor; @indexed nationality nationality; @indexed int height; public profile() { setprofiletype(); } public profile(string firstname, string lastname, nationality nationality, eyecolor eyecolor, haircolor haircolor, int height) { this(); this.setfirstname(firstname); this.setlastname(lastname); this.setnationality(nationality); this.sethaircolor(haircolor); this.seteyecolor(eyecolor); this.setheight(height); } /* getters , setters */ }
and simple class, inherit profile
, , represents civilian:
@nodeentity public class civilian extends profile { @graphproperty(propertytype = long.class) datetime dateofbirth; @indexed boolean missing; @relatedto @fetch set<casualty> casualties = new hashset<casualty>(); //todo: design public civilian() { this.profiletype = profiletype.civilian; } public civilian(string firstname, string lastname, nationality nationality, eyecolor eyecolor, haircolor haircolor, int height, datetime dateofbirth, boolean missing) { super(firstname, lastname, nationality, eyecolor, haircolor, height); this.setdateofbirth(dateofbirth); this.setmissing(missing); } /* getters , setters */ }
so created following repository civilian
class:
public interface civilianrepository extends graphrepository<civilian> { @query("start n=node(*) n.firstname=~{0} return n") page<civilian> findciviliansproperties(string firstname, pageable page); }
ok. created few civilian
nodes, , populated graph them. there no other nodes in graph, except civilian
nodes. when run findciviliansproperties
method, following exception:
exception in thread "main" org.springframework.dao.invaliddataaccessresourceusageexception: error executing statement start n=node(*) n.firstname=~{0} return n skip 0 limit 10; nested exception org.springframework.dao.invaliddataaccessresourceusageexception: error executing statement start n=node(*) n.firstname=~{0} return n skip 0 limit 10; nested exception org.neo4j.cypher.entitynotfoundexception: property 'firstname' not exist on node[0] @ org.springframework.data.neo4j.support.query.cypherqueryengine.query(cypherqueryengine.java:52) @ org.springframework.data.neo4j.repository.query.graphrepositoryquery.dispatchquery(graphrepositoryquery.java:98) @ org.springframework.data.neo4j.repository.query.graphrepositoryquery.execute(graphrepositoryquery.java:81) @ org.springframework.data.repository.core.support.repositoryfactorysupport$queryexecutormethodinterceptor.invoke(repositoryfactorysupport.java:312) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) @ org.springframework.transaction.interceptor.transactioninterceptor$1.proceedwithinvocation(transactioninterceptor.java:96) @ org.springframework.transaction.interceptor.transactionaspectsupport.invokewithintransaction(transactionaspectsupport.java:260) @ org.springframework.transaction.interceptor.transactioninterceptor.invoke(transactioninterceptor.java:94) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) @ org.springframework.dao.support.persistenceexceptiontranslationinterceptor.invoke(persistenceexceptiontranslationinterceptor.java:155) @ org.springframework.aop.framework.reflectivemethodinvocation.proceed(reflectivemethodinvocation.java:172) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:204) @ com.sun.proxy.$proxy33.findciviliansproperties(unknown source) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.springframework.aop.support.aoputils.invokejoinpointusingreflection(aoputils.java:317) @ org.springframework.aop.framework.jdkdynamicaopproxy.invoke(jdkdynamicaopproxy.java:198) @ com.sun.proxy.$proxy36.findciviliansproperties(unknown source) @ org.technion.socialrescue.playground.playground.main(playground.java:38) caused by: org.springframework.dao.invaliddataaccessresourceusageexception: error executing statement start n=node(*) n.firstname=~{0} return n skip 0 limit 10; nested exception org.neo4j.cypher.entitynotfoundexception: property 'firstname' not exist on node[0] @ org.springframework.data.neo4j.support.query.cypherqueryengine.parseandexecutequery(cypherqueryengine.java:63) @ org.springframework.data.neo4j.support.query.cypherqueryengine.query(cypherqueryengine.java:49) ... 20 more caused by: org.neo4j.cypher.entitynotfoundexception: property 'firstname' not exist on node[0] @ org.neo4j.cypher.internal.commands.expressions.property.apply(property.scala:35) @ org.neo4j.cypher.internal.commands.expressions.property.apply(property.scala:29) @ org.neo4j.cypher.internal.commands.regularexpression.ismatch(predicate.scala:259) @ org.neo4j.cypher.internal.pipes.filterpipe$$anonfun$createresults$1.apply(filterpipe.scala:29) @ org.neo4j.cypher.internal.pipes.filterpipe$$anonfun$createresults$1.apply(filterpipe.scala:29) @ scala.collection.iterator$$anon$22.hasnext(iterator.scala:390) @ scala.collection.iterator$$anon$19.hasnext(iterator.scala:334) @ scala.collection.iterator$class.isempty(iterator.scala:272) @ scala.collection.iterator$$anon$19.isempty(iterator.scala:333) @ org.neo4j.cypher.internal.pipes.slicepipe.createresults(slicepipe.scala:32) @ org.neo4j.cypher.internal.pipes.columnfilterpipe.createresults(columnfilterpipe.scala:37) @ org.neo4j.cypher.internal.executionplan.executionplanimpl$$anonfun$6.apply(executionplanimpl.scala:127) @ org.neo4j.cypher.internal.executionplan.executionplanimpl$$anonfun$6.apply(executionplanimpl.scala:125) @ org.neo4j.cypher.internal.executionplan.executionplanimpl.execute(executionplanimpl.scala:33) @ org.neo4j.cypher.executionengine.execute(executionengine.scala:59) @ org.neo4j.cypher.executionengine.execute(executionengine.scala:63) @ org.neo4j.cypher.javacompat.executionengine.execute(executionengine.java:79) @ org.springframework.data.neo4j.support.query.cypherqueryengine.parseandexecutequery(cypherqueryengine.java:61) ... 21 more caused by: org.neo4j.graphdb.notfoundexception: 'firstname' property not found nodeimpl#0. @ org.neo4j.kernel.impl.core.primitive.newpropertynotfoundexception(primitive.java:184) @ org.neo4j.kernel.impl.core.primitive.getproperty(primitive.java:179) @ org.neo4j.kernel.impl.core.nodeimpl.getproperty(nodeimpl.java:52) @ org.neo4j.kernel.impl.core.nodeproxy.getproperty(nodeproxy.java:155) @ org.neo4j.cypher.internal.commands.expressions.property.apply(property.scala:33) ... 38 more
so important thing exception following line - the property 'firstname' not exist on node[0]
.. how can be? there civilian
nodes in graph, , have firstname
property. can neo4j framework adds more hidden nodes graph i'm not aware of? because when change query this:
start n=node(*) has(n.firstname) , n.firstname=~{0} return n
everything works fine...
what wrong?
thanks!!
neo4j
automatically comes 1 node when create new instance, , that's reference node. should delete this.
graphdatabaseservice.getnodebyid(0).delete()
Comments
Post a Comment