Reputation: 7844
I have a repository which is about like the following one, where I'm using an annotated query with parameters. However when it comes to substitution, it fails with the exception: org.neo4j.cypher.ParameterNotFoundException: Expected a parameter named custType1
public class CustTypes {
public static final String TYPE1 = "foo";
public static final String TYPE2 = "bar";
}
public interface CustomQueryRepository extends GraphRepository<CustomEntity> {
@Query(
value =
" START c=node({0}) "
+ " WHERE c.type! = {custType1} "
+ " OR c.type! = {custType2} "
+ "RETURN DISTINCT c, c.type AS compType",
params = {
"custType1", CustTypes.TYPE1,
"custType2", CustTypes.TYPE2
})
Iterable<CustomMapResult> getTypes(List<Long> nodeIds);
}
I also already tried using a named parameter (with @Param
) for nodeIds
which made no difference.
What am I missing here, or can't I mix Query.params
with method parameters?
I'm using spring-data-neo4j version 2.3.0.M1
Thanks, in advance
Upvotes: 1
Views: 573
Reputation: 732
From what I read in the reference documentation, it seems that the param attribute of @Query is only used when fields of entities are annotated with @Query.
EDIT: I actually found an issues which documents this behaviour. I still think it should be mentioned somewehere in the SDN documentation: https://jira.springsource.org/browse/DATAGRAPH-163
TLDR: Param attribute doesnt work in repositories(yet)
Upvotes: 4