title: Intended change in behaviour with cypher in Neo4j 1.9.M02-M05?
body: <p>Is that a known issue, and/or intended behaviour in Neo4j 1.9.M02-M05 that you cannot delete nodes and relationships from cypher queries outside a transaction anymore?</p>
  
  <p>The following example code does work in 1.8.2, but not in 1.9.M02-M05:</p>
  
  <pre><code>ExecutionEngine engine = new ExecutionEngine(graphDb);
  ExecutionResult result = engine.execute("start n = node(*) match (n)&lt;-[r:SOME_TYPE]-() return r");
  
  final Iterator&lt;Relationship&gt; rels = result.columnAs("r");
  assertTrue(rels.hasNext());
  Transaction tx = graphDb.beginTx();
  try {
      rels.next().delete();
      tx.success();
  } finally {
      tx.finish();
  }
  </code></pre>
  
  <p>Stack trace:</p>
  
  <pre><code>org.neo4j.graphdb.TransactionFailureException: Failed to mark transaction as rollback only.
  at org.neo4j.kernel.TopLevelTransaction.markAsRollbackOnly(TopLevelTransaction.java:94)
  at org.neo4j.kernel.PlaceboTransaction.finish(PlaceboTransaction.java:48)
  Caused by: java.lang.NullPointerException
  at org.neo4j.kernel.TopLevelTransaction.markAsRollbackOnly(TopLevelTransaction.java:90)
  </code></pre>
  
  <p>If you move the cypher query into the transaction, it works as before, and as expected:</p>
  
  <pre><code>Transaction tx = graphDb.beginTx();
  
  try {
      ExecutionResult result = engine.execute("start n = node(*) match (n)&lt;-[r:ONE_TO_ONE]-() return r");
      final Iterator&lt;Relationship&gt; rels = result.columnAs("r");
      assertTrue(rels.hasNext());
  
      rels.next().delete();
      tx.success();
  } finally {
      tx.finish();
  }
  </code></pre>
  
  <p>Same with nodes btw.</p>
  
  <p>If you don't use cypher to get the relationship, like f.e. use node.getRelationship() or do an index lookup outside the tx, you can delete the rel.</p>
  
  <p>I've written some tests [1] for structr which all pass with Neo4j 1.8.2, but the two commented out fail with 1.9.M02-1.9.M05 (couldn't test M01 due to dependency problems).</p>
  
  <p>Cheers
  Axel</p>
  
  <p>[1] <a href="https://github.com/structr/structr/blob/develop/structr-core/src/test/java/org/structr/common/CypherNotInTransactionTest.java" rel="nofollow">https://github.com/structr/structr/blob/develop/structr-core/src/test/java/org/structr/common/CypherNotInTransactionTest.java</a></p>
  
  <p><strong>Update:</strong> Seems to be related to lazy evaluation. The following code does not throw the exception:</p>
  
  <pre><code>Relationship r = rels.next();
  
  Transaction tx = graphDb.beginTx();
  
  try {
  
      r.delete();
      tx.success();
  
      [...]
  </code></pre>