John Deverall
John Deverall

Reputation: 6280

Spring-data-neo4j-4 generates invalid cypher when using paging with custom queries

I've read here that spring-data-neo4j-4 now supports paging and sorting in spring-data-neo4j 4.

However the following code is giving me the error below.

Repository Code

@Query("match (m:Member {domainId: {domainId}})-[s:SUBSCRIBER]->(t:MessageThread) return t;")
Page<MessageThread> findByMemberId(Pageable pageable, @Param("domainId") String memberId);

Error message

org.neo4j.ogm.exception.CypherException: Error executing Cypher "Neo.ClientError.Statement.SyntaxError"; Code: Neo.ClientError.Statement.SyntaxError; Description: Invalid input 'K': expected 't/T' or 'e/E' (line 1, column 84 (offset: 83)) "match (m:Member {domainId: {domainId}})-[s:SUBSCRIBER]->(t:MessageThread) return t; SKIP {sdnSkip} LIMIT {sdnLimit}"

I wonder, is this expected or am I doing something wrong?

I'm currently using SDN 4.2.0.M1

Update: Here is the http request (including cypher) that is sent to the neo4j server:

http://localhost:62131/db/data/transaction/commit, request: 

{
    "statements": [{
        "statement": "match (m:Member {domainId: {domainId}})-[s:SUBSCRIBER]->(t:MessageThread) return t; SKIP {sdnSkip} LIMIT {sdnLimit}",
        "parameters": {
            "0": {
                "sort": null,
                "offset": 0,
                "pageNumber": 0,
                "pageSize": 20
            },
            "domainId": "5qfrCXxDQJm5SGpIHtI1yw",
            "sdnSkip": 0,
            "sdnLimit": 20
        },
        "resultDataContents": ["graph"],
        "includeStats": false
    }]
}

Upvotes: 1

Views: 306

Answers (1)

Jasper Blues
Jasper Blues

Reputation: 28766

Looking at your query:

@Query("match (m:Member {domainId: {domainId}})-[s:SUBSCRIBER]->(t:MessageThread) return t;")
Page<MessageThread> findByMemberId(Pageable pageable, @Param("domainId") String memberId);

It ends with a semi-colon. There's a test-case and fix for this error implemented a few weeks ago - available as a SNAPSHOT build.

If you prefer not to use a SNAPSHOT build, you can work around the issue by removing the semi-colon from the end of your custom query.

Upvotes: 2

Related Questions