下面是两个节点实体
user.java
@NodeEntity
public class User {
@GraphId
private Long id;
private String firstName;
private String lastName;
@Fetch @RelatedTo(type = "HAS_ROLE")
private Role role;
...
}
@NodeEntity
public class Role {
@GraphId
private Long id;
private User user;
private Integer role;
...
}
@Query( "Match user-[:HAS_ROLE]-role where user.lastName = 'Lin' return user")
Iterable<User> getUserLin();
错误消息为
org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement Match user-[:HAS_ROLE]-role where user.lastName = 'Lin' return user; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement Match user-[:HAS_ROLE]-role where user.lastName = 'Lin' return user; nested exception is expected 'START'
"Match user-[:HAS_ROLE]-role where user.lastName = 'Lin' return user"
^
at org.springframework.data.neo4j.support.query.CypherQueryEngine.query(CypherQueryEngine.java:56)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:91)
at org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:302)
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:204)
at com.sun.proxy.$Proxy29.getUserLin(Unknown Source)
at org.krams.service.UserService.getUserLin(UserService.java:32)
at org.krams.service.UserService$$FastClassByCGLIB$$fcd59419.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:698)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.aop.interceptor.CustomizableTraceInterceptor.invokeUnderTrace(CustomizableTraceInterceptor.java:257)
at org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke(AbstractTraceInterceptor.java:111)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:631)
at org.krams.service.UserService$$EnhancerByCGLIB$$5d141efb.getUserLin(<generated>)
at org.krams.service.test.UserServiceTester.getUserLinIterTester(UserServiceTester.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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.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.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:88)
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.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement Match user-[:HAS_ROLE]-role where user.lastName = 'Lin' return user; nested exception is expected 'START'
"Match user-[:HAS_ROLE]-role where user.lastName = 'Lin' return user"
^
at org.springframework.data.neo4j.support.query.CypherQueryEngine.parseAndExecuteQuery(CypherQueryEngine.java:67)
at org.springframework.data.neo4j.support.query.CypherQueryEngine.query(CypherQueryEngine.java:53)
... 51 more
Caused by: expected 'START'
"Match user-[:HAS_ROLE]-role where user.lastName = 'Lin' return user"
^
at org.neo4j.cypher.internal.parser.v1_6.CypherParserImpl.parse(CypherParserImpl.scala:65)
at org.neo4j.cypher.CypherParser.parse(CypherParser.scala:42)
at org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:60)
at org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:60)
at org.neo4j.cypher.internal.LRUCache.getOrElseUpdate(LRUCache.scala:31)
at org.neo4j.cypher.ExecutionEngine.prepare(ExecutionEngine.scala:60)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:54)
at org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:57)
at org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:86)
at org.springframework.data.neo4j.support.query.CypherQueryEngine.parseAndExecuteQuery(CypherQueryEngine.java:65)
... 52 more
在Spring Data Neo4J中,我是否必须使用“Start Node...MATCH Relationship...RETURN...”?因为如果下面的查询是成功的:
@Query( "start user=node:User(username={0}) match user-[:HAS_ROLE]-role return user")
User getUserLin(String username);
如果我删除关系和“开始”,它将失败...为什么?(username={0})
中的{0}
表示用户getUserLin(字符串username)
的第一个参数?
@Query( "match user where user.username='John' return user")
User getUserLin();
您可能使用较旧版本的Spring Data Neo4j。match...
语法仅在3.x中支持
有人知道为什么这么简单的查询会出现两个错误吗?错误消息是: 警告:mysqli::准备():无法获取mysqli在(...)/functions.php行503 致命错误:在第504行的(…)functions.php中调用null上的成员函数bind_param()
Sangria.parser.SyntaxError:解析GraphQL查询时出现语法错误。输入结尾意外,应为union、Comments、INTERNECT、SPALEAR、enum、type、inputType或directive(第1行第79列):“Query FetchPokemons{\n pokemonsWithHeight(Height:100){\n NAME\n}\n}” 但是在
问题内容: 我目前在理解和编写递归查询时遇到一些麻烦。我知道递归查询用于搜索信息层次结构,但是我还没有找到一个可以遍历层次结构的简单在线解决方案。例如,假设我有一个对家谱建模的关系: 如果我想编写一个遍历此家谱的递归查询,收集所有父母直到出生,我该如何处理? 提前致谢。 问题答案: 您可以使用子句。 在您的情况下,SQL可能类似于:
本文向大家介绍Oracle基础学习之简单查询和限定查询,包括了Oracle基础学习之简单查询和限定查询的使用技巧和注意事项,需要的朋友参考一下 本文主要介绍的是关于Oracle中的简单查询和限定查询,下面话不多说,来一起看看吧。 SQL: 1,DML(数据操作语言):主要指的是数据库的查询与更新的操作,查询操作是整个sql语法 中最麻烦也是笔试中最常用的部分。 2,DDL(数据
问题内容: 实际上,我有1个查询,但无法将其转换为CakePHP查询格式。 当我将此查询转换为CakePHP时,会出现如下错误: 问题答案: 您可以轻松地在Cake上运行直接SQL查询,例如:$ this-> Picture-> query(“ SELECT * FROM pictures LIMIT 2;”); 或尝试与此类似的东西: ..确保您已正确链接Esl_Userresults和Esl_
问题内容: 我正在尝试使用一个非常简单的方法(不是出于实际目的,而是为了使其正常工作),但是我一直遇到相同的错误。 码 码 最后两行应为我提供每个Post对象的标签数量。在这里,我不断收到相同的错误: 问题答案: 您的示例的问题之一是您不能用作子查询,因为它试图评估查询集并返回计数。 因此,人们可能会认为正确的方法是使用替代方法。也许是这样的: 这不能工作有两个原因: 查询集选择所有字段,而只能依