I think we need more examples in the samples or docs on how to write Cypher Queries in our Spring Data Neo4J Repositories. The sections that talk about putting @Query on your methods is too sparse.
Here is my query as it stands now
And my current exception isCode:@Query("start user=node: " + "match (user)-[:FRIEND]->(friend)-[:FRIEND]->(friendOfFriend) " + "return friendOfFriend " + "order by count(*) desc") public Page<User> findFriendsOfFriends(@Param("node") User user, Pageable pageable);
Caused by: org.neo4j.cypher.SyntaxException: `=' expected but `)' found
I have tried many different versions based on stuff in the docs from
start movie=node:Movie(title='Matrix') match (movie)<-[:ACTS_IN]-(actor) return actor.name
where I have each node in the match in parenthesis like what I have above
To trying not having parentheses because I saw this in the docs
// start person=node:__types__("className"="com...Person")
// where person.age = {0} and person.married = {1}
// return person
And tried this which I found in the docs
If I tryCode:interface MovieRepository extends GraphRepository<Movie> { @Query(" start user=node({0}) match user-[:FRIEND]-friend-[r:RATED]->movie return movie order by avg(r.stars) desc, count(*) desc limit 10 ") Iterabe<Movie> recommendMovies(User me); }
I get a exception trace ofCode:@Query("start user=node({0}) match (user)-[:FRIEND]->(friend)-[:FRIEND]->(friendOfFriend) return friendOfFriend order by count(*) desc") public Page<User> findFriendsOfFriends(User user, Pageable pageable);
So no luckCode:java.util.NoSuchElementException at scala.collection.TraversableLike$$anonfun$2.apply(TraversableLike.scala:372) at scala.collection.TraversableLike$$anonfun$2.apply(TraversableLike.scala:372) at scala.collection.TraversableLike$class.head(TraversableLike.scala:379) at org.neo4j.cypher.pipes.Pipe.head(Pipe.scala:31) at org.neo4j.cypher.pipes.SlicePipe.foreach(SlicePipe.scala:30) at org.neo4j.cypher.pipes.ColumnFilterPipe.foreach(ColumnFilterPipe.scala:35) at scala.collection.TraversableLike$class.map(TraversableLike.scala:194) at org.neo4j.cypher.pipes.Pipe.map(Pipe.scala:31) at org.neo4j.cypher.ExecutionResult$class.javaIterator(ExecutionResult.scala:49) at org.neo4j.cypher.pipes.ColumnFilterPipe.javaIterator(ColumnFilterPipe.scala:25) at org.neo4j.cypher.javacompat.ExecutionResult.iterator(ExecutionResult.java:51) at org.springframework.data.neo4j.conversion.QueryResultBuilder$1.iterator(QueryResultBuilder.java:112) at org.neo4j.helpers.collection.IteratorUtil.addToCollection(IteratorUtil.java:339) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.createPage(GraphRepositoryQuery.java:107) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:88) at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70) at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:301) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) at $Proxy50.findFriendsOfFriends(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196) at $Proxy52.findFriendsOfFriends(Unknown Source) at com.perfectworldprogramming.eventgate.user.UserDBTests.testFindFriendsOfFriends(UserDBTests.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71) at org.junit.runners.ParentRunner.run(ParentRunner.java:236) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174) at org.junit.runner.JUnitCore.run(JUnitCore.java:157) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Will the real slim shady please stand up?
Thanks for you help
Mark


Reply With Quote
