The third option is how it will work, since there's not really nested transactions in neo4j but instead very shallow transactions where there's an existing outer transaction, so practically no overhead.
Transaction tx = db.beginTx(); try { otherMethod( db ); tx.success(); } finally { tx.finish(); } private void otherMethod( GraphDatabaseService db ) { Transaction tx = db.beginTx(); try { // do some other stuff... tx.success(); } finally { tx.finish(); } }
In the above example calling otherMethod() will work with or without an existing transaction. If a transaction exists the operations it performs will take place in it, but if there's no existing transaction one will be created. So both will work.