spring-projects / spring-projects/spring-batch-extensions

A START statement is required

Open
#127 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

module: spring-batch-neo4j status: waiting-for-triage type: bug
Dominant language
Java
Stars
277
Forks
269
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with AbstractNeo4jItemReader.afterPropertiesSet, where the START statement requirement is reported, and BoltResponse.format, where the Neo4j notification causes the NullPointerException. Reproduce the configuration against Neo4j 3.5 using the provided reader settings. Done means the reader's START behavior is compatible with the supported Neo4j version and the reported exception no longer occurs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, neo4j
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.