tx.close() will either commit your transaction if you called tx.success(), or 
roll it back if you either did not call tx.success() or called tx.failure().

When you start a new transaction without closing the one you already have, the 
new transaction will become a sub-transaction of the outer one. In other words, 
transactions can nest, which is useful for composing transactional methods into 
larger transactions. The sub-transactions won't be applied unless you close the 
top-level transaction, though.

--
Chris Vest
System Engineer, Neo Technology
[ skype: mr.chrisvest, twitter: chvest ]


On 05 Oct 2014, at 14:02, Frandro <[email protected]> wrote:

> The following code newly begins transaction each 1000 batch job.
> 
> Is the following code correct?
> 
> Do I have to invoke the tx.close() method each 1000 batch job in the middle?
> 
> It seems there's no problem without calling the method.
> 
> What are success() and close() for? It's confusing.
> 
> Transaction tx = mGraphDb.beginTx();
> 
> int count = 0;
> 
> try
> {
>     if(count % 1000 == 0)
>     {
>         tx.success();
>         tx.close();                                   // should this be 
> called?
>         tx = mGraphDb.beginTx();
>     }
> 
>     count++;
>             
>     tx.success();
> } finally {
>     tx.close();
> }
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to