spring-projects / spring-data-neo4j

Provide support to increase developer productivity in Java when using Neo4j. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
http://spring.io/projects/spring-data-neo4j
Apache License 2.0
825 stars 619 forks source link

@Query(params) usage in Repository throws ParameterNotFoundException: Expected a parameter named type [DATAGRAPH-163] #730

Closed spring-projects-issues closed 7 years ago

spring-projects-issues commented 12 years ago

Hendy Irawan opened DATAGRAPH-163 and commented

Stack trace:

org.springframework.dao.InvalidDataAccessResourceUsageException: Error executing statement START n=node({userId}) MATCH n-[l:LIKE]->y WHERE y.__type__={type} RETURN y LIMIT 10; nested exception is org.neo4j.cypher.ParameterNotFoundException: Expected a parameter named type
    org.springframework.data.neo4j.support.query.CypherQueryEngine.parseAndExecuteQuery(CypherQueryEngine.java:65)
    org.springframework.data.neo4j.support.query.CypherQueryEngine.query(CypherQueryEngine.java:52)
    org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.dispatchQuery(GraphRepositoryQuery.java:91)
    org.springframework.data.neo4j.repository.query.GraphRepositoryQuery.execute(GraphRepositoryQuery.java:70)
    org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:301)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
    org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    $Proxy345.findUserLikesLimit(Unknown Source)

My repository is :

public interface InterestRepository extends GraphRepository<Interest> {

    @Query(value="START n=node({userId}) MATCH n-[l:LIKE]->y WHERE y.__type__={type} RETURN y LIMIT 10",
            params={"type", "com.satukancinta.domain.Interest"})
    public List<Interest> findUserLikesLimit(@Param("userId") long userId);

Affects: 2.1

spring-projects-issues commented 12 years ago

Michael Hunger commented

You are right, this is not supported for repositories as you can pass in parameters there, the parameters attribute was intended for annotated fields (as you don't have any way to pass in parameters there).

For 2.1 we'll add the possibility to specify parameters at the repository method and merge them with the method params.

Until then please either put the type into the query or provide is as parameter at the method call.

Thanks for reporting it

spring-projects-issues commented 12 years ago

Hendy Irawan commented

Thank you Michael for the update :-)

spring-projects-issues commented 7 years ago

Nicolas Mervaillie commented

In order to give users a better vision of what’s happening on SDN, we are bulk closing several issues because they are no more relevant, or related to old and un-maintained SDN versions. We tried to keep the issues that are still relevant, like feature requests that are still absent from SDN. However, some may have been closed by error. If so, please feel free to reopen.