-
Notifications
You must be signed in to change notification settings - Fork 617
Support collections of entities as parameters to custom repository queries. #2292
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
…ository queries. This adds support for collections of entities as parameters. As of know, we try to figure out the common element of that collection and see if we have fitting entity type. If so, all elements are converted into `Map<String, Object>` and put into a list. Another approach would be trying to figure out the declared, resolvable type and than the generic type of a collection, but that would require much bigger changes in the infrastructure. An additional benefit: Heterogenous collections are supported as well to some extend. If this solution posses to be too slow, we can still investigate the generics approach. This closes #2292.
I just trying out the SDN 6.1.2 for custom list params. where as, i'm getting error while accessing the properties of the collection as below: [
{
"description": "some text",
"language": {
"name": "english"
}
},
{
"description": "some text",
"language": {
"name": "french"
}
}
] the above array is the List relations. @Query("UNWIND $relations As rel WITH rel " +
"MATCH (f:PERSON {id: $from}) - [r:KNOWS] -> (t:LANGUAGE {name: rel.language.name}) " +
"RETURN f, collect(r), collect(t)")
UpdatedEntity updateRel(@Param("from") String from,
@Param("relations") List<KnowsEntity> relations); Throws NPE: java.lang.NullPointerException: null may i know how to access the collection variables after UNWIND? |
Hi @venkat125
|
Please have a look at this test: 3bbff33#diff-bebe969e2cc441748447af61880a806dfca39f9fcdf4074de4c445cbcc806908 |
Yep, i tried referring the test.
@ Query("UNWIND $relations As rel WITH rel " + throws:
|
You have to adapt the properties you refer to. In my test, the field annotated with The failure happens in the query itself, not SDN6. |
My Request payload for @ Param("relations")
mapped to following entity class
since language name is the entity's primary identifier as it was in your test. so used __ id __ as in the test
It just returns null on root Object. |
Should be something along these lines
you need to deference the properties of the target node. The query doesn't return anything as |
|
yep that makes sense. Thanks.
To be precise,
and below other things not working (i mean doesn't return anything)
Or
Or
Not sure y the things after |
getting property values Line 72 in 3bbff33
throws error:
It seems i'm missing some local setup to run the tests. |
You can run them against a local instance without Docker by exporting these environment variables: |
Thanks @michael-simons it works when i build the object locally like the one in testcase. I think the issue i'm facing is due to the way the Entity object is being built when parsing the http payload
Using above annotations the constructor includes all the fields including
@michael-simons can you please suggests me to get the result with the way payload as input? |
You could also use the |
Hope this model u was referring to.
|
Disclaimer: I do not have a right environment to check this out right now for myself. |
Tried with the following possible cases:
also tried with |
We do support single entities being converted to a Neo4j map when used with custom queries as documented here: https://docs.spring.io/spring-data/neo4j/docs/6.1.1/reference/html/#custom-queries.parameters.
We don't support collections thereof: https://stackoverflow.com/questions/67992685/spring-data-neo4j-6-query-passing-list-param-throws-converternotfoundexception.
This should be fixed.
The text was updated successfully, but these errors were encountered: