I'm using neo4j-rest-graphdb 2.0.1 (2.0.3 is not available as of today) to access a standalone Neo4j Community 2.0.3 REST Server. In particular, I want to be able to use neo4j-rest-graphdb to group queries into transactions. The README says:
In 1.8 it tries to collect all operations within a tx as a batch-operation which will then be executed on the server.
This has the implication that the results retrieved within that "tx" are not immediately available but only after you called tx.success and tx.finish
However, the following (simplest possible) code that uses a transaction
db = new RestGraphDatabase(<SOMEURL>, <SOMEUSER>, <SOMEPASSWORD>);
System.setProperty(Config.CONFIG_BATCH_TRANSACTION,"true");
Transaction tx = db.beginTx();
// line where exception is thrown
ResourceIterable<Node> it = db.findNodesByLabelAndProperty(DynamicLabel.label(type), "@id", id);
Node result = Iterables.getOnlyElement(it);
tx.success();
tx.finish();
tx.close();
throws a
java.lang.IllegalStateException: received org.neo4j.rest.graphdb.RequestResult@5acc5fb1
at org.neo4j.rest.graphdb.ExecutingRestAPI.toNodeIterableResult(ExecutingRestAPI.java:284)
at org.neo4j.rest.graphdb.ExecutingRestAPI.getNodesByLabelAndProperty(ExecutingRestAPI.java:273)
at org.neo4j.rest.graphdb.RestAPIFacade.getNodesByLabelAndProperty(RestAPIFacade.java:344)
at org.neo4j.rest.graphdb.RestGraphDatabase.findNodesByLabelAndProperty(RestGraphDatabase.java:147)
at {the marked line in the above code}
debugging yields that the fields of the RequestResult that is returned by the Neo4j DB have the following values:
- status: 0
- batchId: 1
- batchResult: true
- string: ""
- all other fields: null
When I set System.setProperty(Config.CONFIG_BATCH_TRANSACTION,"false");
instead of "true", no exception is thrown and the request is returned correctly with correct contents, however not in a transactional context.
Why is that the case?
How can I get (batch-based) transactions with neo4j-rest-graphdb to work properly?