diff --git a/jOOQ/src/main/java/org/jooq/impl/BatchSingle.java b/jOOQ/src/main/java/org/jooq/impl/BatchSingle.java index b24730cae7..bff5166f77 100644 --- a/jOOQ/src/main/java/org/jooq/impl/BatchSingle.java +++ b/jOOQ/src/main/java/org/jooq/impl/BatchSingle.java @@ -162,6 +162,15 @@ class BatchSingle implements BatchBindStep { @Override public final int[] execute() { + + // [#4554] If no variables are bound this should be treated like a + // BatchMultiple as the intention was most likely to call the varargs + // version of DSLContext#batch(Query... queries) with a single parameter. + if (allBindValues.isEmpty()) { + log.info("Single batch", "No bind variables have been provided with a single statement batch execution. This may be due to accidental API misuse"); + return BatchMultiple.execute(configuration, new Query[] { query }); + } + checkBindValues(); // [#1180] Run batch queries with BatchMultiple, if no bind variables @@ -181,12 +190,6 @@ class BatchSingle implements BatchBindStep { } private final int[] executePrepared() { - // [#4554] If no variables are bound this should be treated like a - // BatchMultiple as the intention was most likely to call the varargs - // version of DSLContext#batch(Query... queries) with a single parameter. - if (allBindValues.isEmpty()) { - return BatchMultiple.execute(configuration, new Query[] { query }); - } ExecuteContext ctx = new DefaultExecuteContext(configuration, new Query[] { query }); ExecuteListener listener = new ExecuteListeners(ctx); Connection connection = ctx.connection();