Database Reference
In-Depth Information
It's worth noting that Neo4j does in fact provide batch insertion functionality to allow for
speedybatchinserts.Thisclass,however,isoptimized forspeedanddoesn'tsupporttrans-
actions, instead writing changes to disk as it goes. Such functionality can often be useful
in situations where you have a large dataset that needs to be loaded once, but you need to
be fully aware of the implications of using this facility. For more information, please see
the “Batch Insertion” chapter of the Neo4j Manual: http://docs.neo4j.org/chunked/stable/
batchinsert.html .
In this section, you've seen how to programmatically manage transactions when your code
needs to interact with the graph. This allows you to define atomic units of work and to
have confidence that a successful finish means your changes are durable and that the graph
remains in a consistent state at all times. In the next section, we'll dive a bit deeper into
transactions, including how to use locks as a way of controlling the isolation level of read
transactions. Although this is not required, it's something you may do in certain circum-
stances.
Nested transactions
Neo4j supports flat nested transactions, which means that it's possible to nest transactions,
but inner and outer transactions will ultimately share the same context. If all transactions
call the success method, then all their modifications will be committed to the database.
Ifyouneedtosignalfailureexplicitlyfromaninnertransaction,youcancallthe failure
method, which will mark the whole transaction as failed. In this case, the transaction will
be rolled back and a TransactionFailureException will be thrown at the end of
the outermost transaction.
7.2. Transactions in depth
We've covered the basic workings of transactions in Neo4j, and that should give you
enoughknowledgetohandlethemostcommontransactionalrequirements.Butifyouneed
toachievehigherisolationguaranteesthanthedefaultisolationlevel,ortowritecodethat's
Search WWH ::




Custom Search