-
Notifications
You must be signed in to change notification settings - Fork 617
Expected parameter(s) #2498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
…ner works with anon parameters.
…ner works with anon parameters.
Hi @zhageLiu your english is great, all good, I can make sense of it. Here's what I think is happening: Judging from public interface NodeRepository extends Neo4jRepository<Node, ID>, CypherdslConditionExecutor<Node> {
} This is wrong and does not work! The type The former is a class, the latter a Java annotation. A Spring Data repository contains only domain objects. So given import java.util.UUID;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
@Node
public class DomainModel {
@Id @GeneratedValue UUID id;
private final String name;
public DomainModel(String name) {
this.name = name;
}
public UUID getId() {
return id;
}
public String getName() {
return name;
}
} as domain object (it will have the label import java.util.UUID;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.repository.Neo4jRepository;
import org.springframework.data.neo4j.repository.support.CypherdslConditionExecutor;
public interface DomainModelRepository extends Neo4jRepository<Node, UUID>, CypherdslConditionExecutor<DomainModel> {
} as the repository this code (which basically is your test code) works as expected: Node node = Cypher.node("DomainModel").named("domainModel");
Property name = node.property("name");
Parameter<List<String>> parameters = Cypher.anonParameter(Arrays.asList("A", "C"));
Condition in = name.in(parameters);
Collection<DomainModel> result = repository.findAll(in, Cypher.sort(name).descending());
Assertions.assertThat(result).hasSize(2)
.map(DomainModel::getName)
.containsExactly("C", "A"); Please see this commit 6692b8e for a full example and let me know if this helps. Please spend some time with our documentation, https://docs.spring.io/spring-data/neo4j/docs/current/reference/html/#reference too. |
Thanks for your reply. Here is my new test code domain:
relationship:
repository:
testcode:
they still throw the same error: Expected parameter(s): pcdsl01, i guess the error is run to the while(var9.next) in method name "createNodesAndRelationshipsByIdStatementProvider", this loop is find the node's relationship, then used method of bindAll(), then the cql is generate:
when this cql is parsing, the placeholder name "$pcdsl01" is not in the param "parameters", so when run query with this cql, this cql didn't parsing to the ture params like ["a", "b"], but still is pcdsl01, so throw this error. i'm a beginner for java and neo4j, if I wasn't clear or if I was wrong, please forgive me, thanks |
and my pom is |
I tested other methods of findAll, like eq, gt, lt... They all throw the same exception.
What they all have in common is this:
|
hello @michael-simons, did you see my reply? this error confused me, please read and help me |
Hi @zhageLiu I can reproduce this with your domain and we are investigating. |
hi @michael-simons thanks for your reply, i hope my analysis can be of some help to your team |
That was faster than expected now to debunk. First of all, big thank you to you for being persistent on this issue, much appreciated. This will be fixed in the next patches, but here's already an explanation: The Now, with your domain model, we do issue several queries to make sure we don't create a super big one running in circles (your domain has a "self referential" relationship). We must add the parameters to each of the statements. Well: spring-data-neo4j/src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java Lines 1095 to 1098 in 25d346e
I wanted to do this (see |
thank you and your team, and can you tell me this message when the patches release? thanks again |
Please check https://calendar.spring.io for the planned dates. This is out of our hands, the Spring Data Team at VMWare lead by @mp911de decides and runs the release. I'm backporting this back to 6.1.x. |
…ner works with anon parameters.
…ner works with anon parameters.
this is my code:
i try to run these, then throw the ClientException:Expected parameter(s)
and i debug these
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!
The text was updated successfully, but these errors were encountered: