What does the API mean?
The intent of the API is to provide a set of bind values for a batch statement in a matrix form where each outer array element corresponds to an individual statement in the batch, and each inner array element corresponds to a bind value.
How is it called?
There are several ways. Let's assume this query here:
Query query = DSL.query("INSERT INTO t(a, b) VALUES (?, ?)", null, null);
E.g. using classic matrix creation in Java (the varargs isn't helpful here):
batch(query, new Object[][] {
{ 1, "a" }, // Record 1 to insert
{ 2, "b" }, // Record 2 to insert
{ 3, "c" } // Record 3 to insert
});
Or, by using individual arrays (this is where varargs may help):
batch(query,
new Object[] { 1, "a" }, // Record 1 to insert
new Object[] { 2, "b" }, // Record 2 to insert
new Object[] { 3, "c" } // Record 3 to insert
);
The latter is particularly useful if you have some pre-existing jOOQ record structure, and you want to pass them as bind variables to a batch, e.g. by using Record.intoArray()
:
batch(query,
record1.intoArray(),
record2.intoArray(),
record3.intoArray()
);