Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-29-2021 11:44 PM
Hello,
Assuming I have Surname Unique ( is an Example... )
@Query("MATCH (n:User:`$surname`) return n ")
Flux<UserEntity> customFindAll(@Param("surname") String surname);
<- This query doesnt work in spring-data otherwise was too easy of course...
How can I write a query with a dynamic surname in input @Param ?
in this case I am trying to make a customFindAll -> ( Please note that I don't need the findAll for Id , but another parameter, like in this case the surname.. )
Thank you as always for your time.
Andrea.
Solved! Go to Solution.
11-30-2021 12:19 AM
The query won't work in Neo4j itself either. Labels are a statically compiled part of the Query, one cannot use parameters for them.
In case you mistake Labels with properties, the following query would work:
@Query("MATCH (n:User {userName: $surname}) return n ")
Gives you all nodes with a label User
and a property userName
equals to your parameter.
In case you did indeed store usernames as additional labels, I would go with
MATCH (n:User) WHERE $surname IN labels(n) RETURN n
11-30-2021 12:19 AM
The query won't work in Neo4j itself either. Labels are a statically compiled part of the Query, one cannot use parameters for them.
In case you mistake Labels with properties, the following query would work:
@Query("MATCH (n:User {userName: $surname}) return n ")
Gives you all nodes with a label User
and a property userName
equals to your parameter.
In case you did indeed store usernames as additional labels, I would go with
MATCH (n:User) WHERE $surname IN labels(n) RETURN n
All the sessions of the conference are now available online