public <U> Maybe<U> transaction(io.reactivex.functions.Function<ReactiveRXGenericQueryExecutor, Maybe<U>> transaction){
        return beginTransaction()
                .toMaybe()
                .flatMap(queryExecutor -> transaction.apply(queryExecutor) //perform user tasks
                        .flatMap(res -> queryExecutor.commit() //commit the transaction
                                .andThen(Maybe.just(res)))) //and return the result
                ;
    }
public < U > Maybe < U > transaction ( io . reactivex . functions . Function < ReactiveRXGenericQueryExecutor , Maybe < U > > transaction ) { return beginTransaction ( ) . toMaybe ( ) . flatMap ( queryExecutor -> transaction . apply ( queryExecutor ) . flatMap ( res -> queryExecutor . commit ( ) . andThen ( Maybe . just ( res ) ) ) ) ; }
Convenience method to perform multiple calls on a transactional QueryExecutor, committing the transaction and
returning a result.
@param transaction your code using a transactional QueryExecutor.
<pre>
{@code
ReactiveRXGenericQueryExecutor nonTransactionalQueryExecutor...;
Maybe<QueryResult> resultOfTransaction = nonTransactionalQueryExecutor.transaction(transactionalQueryExecutor ->
{
//make all calls on the provided QueryExecutor that runs all code in a transaction
return transactionalQueryExecutor.execute(dslContext -> dslContext.insertInto(Tables.XYZ)...)
.compose(i -> transactionalQueryExecutor.query(dslContext -> dslContext.selectFrom(Tables.XYZ).where(Tables.XYZ.SOME_VALUE.eq("FOO")));
}
);
}
</pre>
@param <U> the return type.
@return the result of the transaction.