Closed
Description
this is my code:
Node node = Cypher.node("Node").named("node");
Property name= node.property("name");
Parameter<List<String>> parameters = Cypher.anonParameter( nameList );
Condition in = property.in(parameters );
Collection<Node> all = nodeRepository.findAll(in);
i try to run these, then throw the ClientException:Expected parameter(s)
and i debug these
package org.springframework.data.neo4j.repository.query;
public Collection<T> findAll(Condition condition) {
return this.neo4jOperations.toExecutableQuery(this.metaData.getType(), QueryFragmentsAndParameters.forCondition(this.metaData, condition, (Pageable)null, (Collection)null)).getResults();
}
package org.springframework.data.neo4j.core;
public List<T> getResults() {
Collection<T> all = (Collection)this.createFetchSpec().map(RecordFetchSpec::all).orElse(Collections.emptyList());
return this.preparedQuery.resultsHaveBeenAggregated() ? (List)all.stream().flatMap((nested) -> {
return ((Collection)nested).stream();
}).distinct().collect(Collectors.toList()) : (List)all.stream().collect(Collectors.toList());
}
private Optional<RecordFetchSpec<T>> createFetchSpec() {
******
if (cypherQuery == null || containsPossibleCircles) {
if (containsPossibleCircles && !queryFragments.isScalarValueReturn()) {
NodesAndRelationshipsByIdStatementProvider nodesAndRelationshipsById = this.createNodesAndRelationshipsByIdStatementProvider(entityMetaData, queryFragments, queryFragmentsAndParameters.getParameters());
if (nodesAndRelationshipsById.hasRootNodeIds()) {
return Optional.empty();
}
cypherQuery = Neo4jTemplate.renderer.render(nodesAndRelationshipsById.toStatement(entityMetaData));
finalParameters = nodesAndRelationshipsById.getParameters();
} else {
******
}
}
******
}
private NodesAndRelationshipsByIdStatementProvider createNodesAndRelationshipsByIdStatementProvider(Neo4jPersistentEntity<?> entityMetaData, QueryFragments queryFragments, Map<String, Object> parameters) {
Statement rootNodesStatement = Neo4jTemplate.this.cypherGenerator.prepareMatchOf(entityMetaData, queryFragments.getMatchOn(), queryFragments.getCondition()).returning(new String[]{"__sn__"}).build();
Map<String, Object> usedParameters = new HashMap(parameters);
usedParameters.putAll(rootNodesStatement.getParameters());
******(①)******
Collection<Long> rootNodeIds = new HashSet((Collection)((RunnableSpec)Neo4jTemplate.this.neo4jClient.query(Neo4jTemplate.renderer.render(rootNodesStatement)).bindAll(usedParameters)).fetchAs(Value.class).mappedBy((t, r) -> {
return r.get("__sn__");
}).one().map((value) -> {
return value.asList(Value::asLong);
}).get());
if (rootNodeIds.isEmpty()) {
return NodesAndRelationshipsByIdStatementProvider.EMPTY;
} else {
Set<Long> relationshipIds = new HashSet();
Set<Long> relatedNodeIds = new HashSet();
queryFragments.getClass();
Iterator var9 = entityMetaData.getRelationshipsInHierarchy(queryFragments::includeField).iterator();
while(var9.hasNext()) {
RelationshipDescription relationshipDescription = (RelationshipDescription)var9.next();
Statement statement = Neo4jTemplate.this.cypherGenerator.prepareMatchOf(entityMetaData, relationshipDescription, queryFragments.getMatchOn(), queryFragments.getCondition()).returning(Neo4jTemplate.this.cypherGenerator.createReturnStatementForMatch(entityMetaData)).build();
usedParameters = new HashMap(parameters);
usedParameters.putAll(statement.getParameters());
******②******
((RunnableSpec)Neo4jTemplate.this.neo4jClient.query(Neo4jTemplate.renderer.render(statement)).bindAll(parameters)).fetch().one().ifPresent(this.iterateAndMapNextLevel(relationshipIds, relatedNodeIds, relationshipDescription, PropertyPathWalkStep.empty()));
}
return new NodesAndRelationshipsByIdStatementProvider(rootNodeIds, relationshipIds, relatedNodeIds, queryFragments);
}
}
when i run to code ①, the method of bindAll have params with name "usedParameters", and my cql is true ,the field with name "runnableStatement" , have field "parameters" ,and this filde value is my cql Should have parameters, is true.
but when i run to code ②, bindAll() have params with name "parameters", but this param is empty, and the field of "runnableStatement" - "parameters" is empty, so my cql is wrong, finally throw the Exception: Expected parameter(s)
my English is not good, i hope you see what I mean, and I don't understand what's wrong with me, please help me
thank you!