Skip to content

Resolve or remove literal replacements in custom count queries. #2239

@jposthauer

Description

@jposthauer

I have the following query where I am trying to have a dynamic sort and paging using a Pageable parameter.

  @Query(value = "MATCH (person:Person) "
      + "WHERE toUpper(person.name) CONTAINS toUpper($name) "
      + "WITH DISTINCT(person) AS person "
      + ":#{orderBy(#pageable)} RETURN person SKIP $skip LIMIT $limit;",
      countQuery = "MATCH (person:Person) "
          + "WHERE toUpper(person.name) CONTAINS toUpper($name) "
          + "RETURN COUNT(DISTINCT person);")
  Page<Person> findByName(String name, Pageable pageable);

When I run the query I get an error stating Unable to convert org.springframework.data.neo4j.repository.query.Neo4jSpelSupport$StringBasedLiteralReplacement to Neo4j Value.

If I remove the count query and change the return type to Slice<Person> everything returns fine, so the issue comes when translating the count query.

After digging into the SDN code I found that the issue occurs when getCountQuery is called, it is including the SpEL__0__ parameter in it's parameter list even though the count query doesn't use that parameter.

The issue and full stacktrace is identical to the issue identified in the thread of this issue: #1219 #1219

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions