spring-projects / spring-batch-extensions

Spring Batch Extensions
242 stars 258 forks source link

A START statement is required #127

Open BugHunterPhilosopher opened 4 years ago

BugHunterPhilosopher commented 4 years ago

Bug description

When I use a Neo4jItemReader, like this:

val positionItemReader = new Neo4jItemReader<Position>();
positionItemReader.setStartStatement("n = node(6490)");

I get the following error notification: notification.title = "The RULE planner is not available in the current CYPHER version, the query has been run by an older CYPHER version." notification.description = "START is not supported for current CYPHER version, the query has been executed by an older CYPHER version"

Which looks accurate for Neo4j 3.5, as the START clause seems to be deprecated.

Here is the exception:

java.lang.NullPointerException
        at org.neo4j.ogm.drivers.bolt.response.BoltResponse.format(BoltResponse.java:136)
        at org.neo4j.ogm.drivers.bolt.response.BoltResponse.lambda$logNotifications$0(BoltResponse.java:116)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
        at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1085)
        at org.neo4j.ogm.drivers.bolt.response.BoltResponse.logNotifications(BoltResponse.java:104)
        at org.neo4j.ogm.drivers.bolt.response.BoltResponse.process(BoltResponse.java:92)
        at org.neo4j.ogm.drivers.bolt.response.BoltResponse.close(BoltResponse.java:67)
        at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.lambda$executeAndMap$1(ExecuteQueriesDelegate.java:172)

But if I do this:

val positionItemReader = new Neo4jItemReader<Position>();
positionItemReader.setStartStatement(" ");

It fails too because the start clause is mandatory:

Caused by: java.lang.IllegalStateException: A START statement is required
    at org.springframework.util.Assert.state(Assert.java:76) ~[spring-core-5.2.9.RELEASE.jar:5.2.9.RELEASE]
    at org.springframework.batch.item.data.AbstractNeo4jItemReader.afterPropertiesSet(AbstractNeo4jItemReader.java:200) ~[spring-batch-infrastructure-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792) **~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]**

Are you sure the START clause is still mandatory, with modern Neo4j? What shall I do, please?

Environment I use Spring batch (spring-batch-infrastructure-4.2.4.RELEASE.jar), Neo4j driver (neo4j-ogm-bolt-driver 3.2.17) and Neo4j 3.5 in Java 11.

Steps to reproduce

@Bean
  public Neo4jItemReader<Position> positionItemReader() {
    val positionItemReader = new Neo4jItemReader<Position>();
    positionItemReader.setSessionFactory(this.sessionFactory);
    positionItemReader.setName("Position-Reader");
    positionItemReader.setTargetType(Position.class);
    positionItemReader.setPageSize(1);
    positionItemReader.setStartStatement("n = node(6490)");
    positionItemReader.setMatchStatement("(p: Position)");
    positionItemReader.setReturnStatement("p");
    positionItemReader.setOrderByStatement("p.symbol");
    positionItemReader.setParameterValues(new HashMap<>());

    return positionItemReader;
  }

Expected behavior

Maybe I shall use a Neo4jItemReader without a START clause, as it is deprecated?

Thanks in advance.