From 7ef9246a6e75ce7bf227ace5634accbe18f8194f Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Wed, 7 Feb 2024 11:10:05 +0100 Subject: [PATCH] [jOOQ/jOOQ#16217] Add ExecuteContext.params(): Param[] --- .../main/java/org/jooq/ExecuteContext.java | 16 ++++ .../main/java/org/jooq/ExecuteListener.java | 80 ++++++++++++++----- .../org/jooq/impl/DefaultExecuteContext.java | 15 ++++ .../org/jooq/impl/SimpleExecuteContext.java | 11 +++ 4 files changed, 104 insertions(+), 18 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/ExecuteContext.java b/jOOQ/src/main/java/org/jooq/ExecuteContext.java index 23d333601b..8dd8fa4060 100644 --- a/jOOQ/src/main/java/org/jooq/ExecuteContext.java +++ b/jOOQ/src/main/java/org/jooq/ExecuteContext.java @@ -243,6 +243,22 @@ public interface ExecuteContext extends Scope { */ void sql(String sql); + /** + * The bind values that are being bound to the {@link PreparedStatement}. + */ + Param @NotNull [] params(); + + /** + * Override the bind values that are being bound to the + * {@link PreparedStatement}. + *

+ * This may have no effect, if called at the wrong moment. + * + * @see ExecuteListener#renderEnd(ExecuteContext) + * @see ExecuteListener#prepareStart(ExecuteContext) + */ + void params(Param[] params); + /** * The number of user defined update counts that are going to be skipped * when a statement batch is executed. diff --git a/jOOQ/src/main/java/org/jooq/ExecuteListener.java b/jOOQ/src/main/java/org/jooq/ExecuteListener.java index f248c71cd2..8a77364e85 100644 --- a/jOOQ/src/main/java/org/jooq/ExecuteListener.java +++ b/jOOQ/src/main/java/org/jooq/ExecuteListener.java @@ -375,7 +375,9 @@ public interface ExecuteListener extends EventListener, Serializable { * a jOOQ routine is being executed or null otherwise *

  • {@link ExecuteContext#sql()}: The rendered SQL statement * that is about to be executed, or null if the - * SQL statement is unknown..
  • + * SQL statement is unknown. + *
  • {@link ExecuteContext#params()}: The bind values that are bound to + * the {@link PreparedStatement}.
  • * *

    * Overridable attributes in ExecuteContext: @@ -383,6 +385,8 @@ public interface ExecuteListener extends EventListener, Serializable { *

  • {@link ExecuteContext#sql(String)}: The rendered SQL * statement that is about to be executed. You can modify this statement * freely.
  • + *
  • {@link ExecuteContext#params(Param[])}: Bind values that are to be + * bound to the {@link PreparedStatement}.
  • * * * @param ctx The context containing information about the execution. @@ -472,7 +476,9 @@ public interface ExecuteListener extends EventListener, Serializable { * a jOOQ routine is being executed or null otherwise *
  • {@link ExecuteContext#sql()}: The rendered SQL statement * that is about to be executed, or null if the - * SQL statement is unknown..
  • + * SQL statement is unknown. + *
  • {@link ExecuteContext#params()}: The bind values that are bound to + * the {@link PreparedStatement}.
  • * *

    * Overridable attributes in ExecuteContext: @@ -480,6 +486,8 @@ public interface ExecuteListener extends EventListener, Serializable { *

  • {@link ExecuteContext#sql(String)}: The rendered SQL * statement that is about to be executed. You can modify this statement * freely.
  • + *
  • {@link ExecuteContext#params(Param[])}: Bind values that are to be + * bound to the {@link PreparedStatement}.
  • *
  • {@link ExecuteContext#statement()}: The {@link PreparedStatement} * about to be executed. At this stage, no such statement is available yet, * but if provided, the execution lifecycle will skip preparing a statement. @@ -521,7 +529,9 @@ public interface ExecuteListener extends EventListener, Serializable { * a jOOQ routine is being executed or null otherwise
  • *
  • {@link ExecuteContext#sql()}: The rendered SQL statement * that is about to be executed, or null if the - * SQL statement is unknown..
  • + * SQL statement is unknown. + *
  • {@link ExecuteContext#params()}: The bind values that are bound to + * the {@link PreparedStatement}.
  • *
  • {@link ExecuteContext#statement()}: The * PreparedStatement that is about to be executed, or * null if no statement is known to jOOQ. This can be any of @@ -542,6 +552,8 @@ public interface ExecuteListener extends EventListener, Serializable { *

    * Overridable attributes in ExecuteContext: *