title: How to get Node object when using Neo4j jdbc?
body: <p>I used neo4j-rest-binding in my project, but I face some transaction issue, so I want to control transaction by my self. I found neo4j-jdbc is a good option, and it sounds have more pros than neo4j-rest-binding from the article in google forum. (<a href="https://groups.google.com/forum/#!topic/neo4j/4DG_R5Yh2BM" rel="nofollow">https://groups.google.com/forum/#!topic/neo4j/4DG_R5Yh2BM</a>)</p>
  
  <p>I used neo4j-rest-binding to do query and I can transform the result to Node object.</p>
  
  <pre><code>QueryResult&lt;Map&lt;String, Object&gt;&gt; result = engine.query("MATCH (n) RETURN n")
  Iterator&lt;Node&gt; nodeIter = result.to(Node.class).iterator();
  // if I want to get the relationship of the node
  Iterator&lt;Relationship&gt; outRelIter = node.getRelationships(Direction.OUTGOING).iterator();
  ...
  </code></pre>
  
  <p>But when I use neo4j-jdbc to do query, I don't know how to get Node object...</p>
  
  <pre><code>ResultSet rs = stmt.executeQuery("MATCH (n) RETURN n");
  while(rs.next()) {  
      Map&lt;String, Object&gt; res = (Map&lt;String, Object&gt;) rs.getObject("n");
      // how to get Node object?
  }
  </code></pre>
  
  <p>Another question is if I use <code>tx.fail()</code>, <code>tx.success()</code> and <code>tx.finish()</code>, how could I know when the transaction fail? I know it will rollback if <code>tx.success</code> is not called, but since I combine MongoDB and Neo4j, I want to rollback MongoDB when Neo4j fail. such like:</p>
  
  <pre><code>//Do some MongoDB operation...
  ...
  
  //Do some Neo4j operation...
  tx.begin();
  try {
      ...
      if(???) // if transaction fail
          // rollback MongoDB
      else
          tx.success();
  } finally {
      tx.close();
  }
  </code></pre>
  
  <p>Does it work when I use neo4j-jdbc? (I have answered this question by myself)</p>
  
  <pre><code>try {
      conn.setAutoCommit(false); // for Neo4j
      //Do some MongoDB operation...
      ...
  
      //Do some Neo4j operation...
      conn.commit();
  } catch(SQLException e) {
      conn.rollback(); // for Neo4j
      // rollback MongoDB
  }
  </code></pre>
  
  <p>Many thanks!</p>