Announcement Announcement Module
Collapse
No announcement yet.
Neo4jTemplate query method does not seem to return the same result as native api Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Neo4jTemplate query method does not seem to return the same result as native api

    Using Spring Data I've written the code below using the Neo4jTemplate:

    Code:
    Result<Map<String, Object>> result = neo4jTemplate.query(
        "START n = node:`n.name`(name = \"name\") MATCH (n)-[c:CONNECTS]->(x) RETURN x ORDER BY c.`order`",
         new HashMap<String, Object>()
    );
    When I execute this code I get no results. After verifying that my query works correctly using the Neo4j web console, I rewrote my Spring Data code using the native Neo4j API:

    Code:
    ExecutionEngine executionEngine = new ExecutionEngine(graphDatabaseService, StringLogger.SYSTEM);
    
    ExecutionResult queryResult = executionEngine.execute(
        "START n = node:`n.name`(name = \"name\") MATCH (n)-[c:CONNECTS]->(x) RETURN x ORDER BY c.`order`"
    );
    When executing this code I do receive the correct amount of items from the query. Am I doing something wrong here when working with the Neo4jTemplate or is there no support for this type of query built-in in the Neo4jTemplate?

    I am having the exact same problem when annotating a field using @Query and setting the value of this annotation to the query I wrote in the previous code fragment.

  • #2
    After a lot of testing I decided to upgrade my Neo4j version from 1.8.2 to 1.9.M02, which contains the same issue. Finally after an other upgrade to version 1.9.RC2 of Neo4j the issue seems to be resolved. I'm still not able to use the @Query annotation on fields.

    When I use this annotation on a field I get a ClassCastException:

    Code:
    org.springframework.data.neo4j.conversion.QueryResultBuilder$1 cannot be cast to be.dries.MyNodeEntity.
    Does anyone know what I'm doing wrong here?

    Comment

    Working...
    X