【发布时间】:2023-02-15 11:15:38
【问题描述】:
我想运行以下查询,但是出现了一些错误。我在 neo4j 工作区上测试了我的查询,它正在运行。我找不到使用 IN 查询的 Java 驱动程序的任何源代码,所以我不确定我的代码有什么问题。我正在使用 Neo4j Java 驱动程序 4.4。
ArrayList<String> changedMethods = ...
Query query = new Query(
"MATCH (changedFunction: Function) WHERE changedFunction.signature IN $changedMethods \n" +
"MATCH (affectedFunction: Function)-[:CALLS]->(changedFunction) \n" +
"RETURN affectedFunction.functionName", parameters("changedMethods", changedMethods));
try (Session session = driver.session(SessionConfig.forDatabase("neo4j"))) {
List<Record> a = session.readTransaction(tx -> tx.run(query)).list();
System.out.println(a.get(0).toString());
}
运行此代码后,出现以下错误
org.neo4j.driver.exceptions.ResultConsumedException: Cannot access records on this result any more as the result has already been consumed or the query runner where the result is created has already been closed.
【问题讨论】:
-
我不认为这与 IN 查询有任何关系。你不需要阅读
list()的结果吗?里面你的交易,不在外面? -
@knittl 是的,你是对的。在事务中移动 list() 解决了这个问题。谢谢。
标签: java neo4j neo4j-java-api