/** * Perform a transaction, with the option to automatically retry on failure. * * @param db {@link GraphDatabaseService} to apply the transaction on. * @param retry {@link RetryHandler} deciding what type of failures to retry on. * @param transaction {@link Consumer} containing the transaction logic. */ public static void tx( GraphDatabaseService db, RetryHandler retry, Consumer<? super GraphDatabaseService> transaction ) { Function<? super GraphDatabaseService,Void> voidFunction = _db -> { transaction.accept( _db ); return null; }; tx( db, true, retry, voidFunction ); }
private <T> T transaction( Function<? super GraphDatabaseService, T> function, boolean commit ) { return tx( getGraphDatabaseAPI(), commit, RetryHandler.NO_RETRY, function ); }
@Test public void tx_createNode_addLabel_setProperty() { db.when( db.tx( createNode().andThen( addLabel( label( "Label1" ) ).andThen( setProperty( "key1", "value1" ) ) ) ) ); }
@After public void then() { assertThat( "Matching nodes from index lookup", db.when( db.tx( listNodeIdsFromIndexLookup( label( "Label1" ), "key1", "value1" ) ) ), hasSize( 1 ) ); }
/** * Perform a transaction, with the option to automatically retry on failure. * * @param db {@link GraphDatabaseService} to apply the transaction on. * @param retry {@link RetryHandler} deciding what type of failures to retry on. * @param transaction {@link Consumer} containing the transaction logic. */ public static void tx( GraphDatabaseService db, RetryHandler retry, Consumer<? super GraphDatabaseService> transaction ) { Function<? super GraphDatabaseService,Void> voidFunction = _db -> { transaction.accept( _db ); return null; }; tx( db, true, retry, voidFunction ); }
private <T> T transaction( Function<? super GraphDatabaseService, T> function, boolean commit ) { return tx( getGraphDatabaseAPI(), commit, RetryHandler.NO_RETRY, function ); }