1

I have about 20000 odd nodes and relationships in my neo4j schema. I am trying to query that data and display in my browser. I am using the neo-4j java driver with Spring jdbcTemplate. But below query MATCH(n)<-[r]-(m) return n,type(r),m limit 100

 final String GRAPH_QUERY = "MATCH(n)<-[r]-(m) return n,type(r),m limit 100";

    Iterator<Map<String, Object>> result = template.queryForList(
            GRAPH_QUERY, limit == null ? 100 : limit).iterator();
     while ( result.hasNext() )
        { 
              //store result in a hashmap or something
       }
      //There is only one row returned in the result above.

it is returning only one row in Java, whereas this same query returns all the nodes and relationships if i run it in neo4j shell or from console. Pretty strange. Any reasons ?

pom.xml dependencies

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jdbc</artifactId>
        <version>${spring-boot.version}</version>
    </dependency>
    <dependency>
        <groupId>org.neo4j.driver</groupId>

        <artifactId>neo4j-java-driver</artifactId>

        <version>1.0.3</version>
    </dependency>
    <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-jdbc</artifactId>
            <version>2.3.2</version>
    </dependency>
   <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jetty</artifactId>
        <version>${spring-boot.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.1.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpcore</artifactId>
        <version>4.1</version>
    </dependency>

There is nothing much to the code apart from what I have posted above. If I iterate using the result iterator , its giving me only one result.

Manu Bhat
  • 135
  • 2
  • 8
  • can you please add your `pom.xml` file content? – Supamiu Jun 15 '16 at 13:02
  • you can't use the neo4j-java-driver with the jdbc template, you can only use the jdbc-driver with the jdbc-template – Michael Hunger Jun 15 '16 at 14:20
  • Can you share your full code + dependencies? – Michael Hunger Jun 15 '16 at 14:21
  • @Manu Bhat Did you ever figure this out? I've got a similar issue where `transaction.execute(query)` returns a result that contains multiple rows according to `result.resultAsString()`, but only a single row according to `hasNext()`/`.next()`. I'm completely stumped. – mcv Jul 07 '22 at 20:37

0 Answers0