[jOOQ/jOOQ#15249] Add ExecuteContext.skipUpdateCounts to allow for setting the AbstractContext.skipUpdateCounts flag in an ExecuteListener
This commit is contained in:
parent
49713f680b
commit
28dac4ecc7
@ -48,6 +48,7 @@ import java.util.stream.Collector;
|
||||
import org.jooq.conf.Settings;
|
||||
import org.jooq.conf.StatementType;
|
||||
import org.jooq.exception.DataAccessException;
|
||||
import org.jooq.impl.CustomQueryPart;
|
||||
import org.jooq.impl.DSL;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -242,6 +243,31 @@ public interface ExecuteContext extends Scope {
|
||||
*/
|
||||
void sql(String sql);
|
||||
|
||||
/**
|
||||
* The number of user defined update counts that are going to be skipped
|
||||
* when a statement batch is executed.
|
||||
* <p>
|
||||
* This is in <em>addition</em> to any skips added during the rendering of a
|
||||
* {@link QueryPart} by jOOQ's internals or by user-defined query parts,
|
||||
* such as {@link CustomQueryPart}.
|
||||
*/
|
||||
int skipUpdateCounts();
|
||||
|
||||
/**
|
||||
* Override the number of update counts that are going to be skipped when a
|
||||
* statement batch is executed.
|
||||
* <p>
|
||||
* This is in <em>addition</em> to any skips added during the rendering of a
|
||||
* {@link QueryPart} by jOOQ's internals or by user-defined query parts,
|
||||
* such as {@link CustomQueryPart}.
|
||||
* <p>
|
||||
* This may have no effect, if called at the wrong moment.
|
||||
*
|
||||
* @see ExecuteListener#renderEnd(ExecuteContext)
|
||||
* @see ExecuteListener#prepareStart(ExecuteContext)
|
||||
*/
|
||||
void skipUpdateCounts(int skip);
|
||||
|
||||
/**
|
||||
* The generated SQL statements that are being executed in batch mode, or
|
||||
* empty if the query is unknown or if there was no SQL statement.
|
||||
|
||||
@ -934,7 +934,7 @@ abstract class AbstractContext<C extends Context<C>> extends AbstractScope imple
|
||||
|
||||
@Override
|
||||
public final int skipUpdateCounts() {
|
||||
return skipUpdateCounts;
|
||||
return skipUpdateCounts + (ctx != null ? ctx.skipUpdateCounts() : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -88,7 +88,6 @@ import org.jooq.conf.Settings;
|
||||
import org.jooq.tools.JooqLogger;
|
||||
import org.jooq.tools.jdbc.JDBCUtils;
|
||||
import org.jooq.tools.reflect.Reflect;
|
||||
import org.jooq.tools.reflect.ReflectException;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@ -119,6 +118,7 @@ class DefaultExecuteContext implements ExecuteContext {
|
||||
private Query query;
|
||||
private final Routine<?> routine;
|
||||
private String sql;
|
||||
private int skipUpdateCounts;
|
||||
|
||||
private final BatchMode batchMode;
|
||||
private Query[] batchQueries;
|
||||
@ -545,6 +545,16 @@ class DefaultExecuteContext implements ExecuteContext {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int skipUpdateCounts() {
|
||||
return this.skipUpdateCounts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skipUpdateCounts(int skip) {
|
||||
this.skipUpdateCounts = skip;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String[] batchSQL() {
|
||||
return batchMode != BatchMode.NONE
|
||||
|
||||
@ -150,6 +150,16 @@ final class SimpleExecuteContext extends AbstractScope implements ExecuteContext
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int skipUpdateCounts() {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void skipUpdateCounts(int skip) {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String[] batchSQL() {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user