Combining with Statement, one can do batch in the following fashion.
Statement.add needs to invoked correctly.
Save the current binding and create a new one to indicate the statement should be executed again with new bindings provided through subsequent calls to bind and bindNull.
Otherwise, java.lang.IllegalStateException: Not all parameter values are provided yet. might occur.
Batch doesn’t support bind. It only can work with string. Unless the batch update only involve constant, which sounds unlikely, sql-injection should be a concern, using Statement should be a safer approach.
Compose batches
Flux.thenMany could be use to compose two Flux.from(Statement.execute)
Transaction
One can add transaction management around the batch update in the follow fashion.
In reactor, sometime we want to give certain operation return type like Mono<Void>, like we don’t need any information from the operation, as long as the operation succeed. In this sense, we are using Void as Unit type
The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.
So Void supposes to be uninstantiable, but in practices, people use it as unit type along with null
implication in project reactor
In project reactor, there is Mono.zip
Aggregate given monos into a new Mono that will be fulfilled when all of the given Monos have produced an item, aggregating their values according to the provided combinator function. An error or empty completion of any source will cause other sources to be cancelled and the resulting Mono to immediately error or complete, respectively.